-
Notifications
You must be signed in to change notification settings - Fork 786
Apollo react import not transpiled when running jest tests #1663
Comments
If you are on the beta, I suspect that it is trying to read the Here's my jest config (using typescript but much the same) - note that the alienfast/lodash are modules (not ES5): module.exports = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testMatch: ['<rootDir>/src/**/?(*.)test.ts?(x)'],
moduleNameMapper: {
'^react-native$': 'react-native-web',
},
transform: {
'^.+\\.(j|t)sx?$': 'ts-jest',
'^(?!.*\\.json$)': '<rootDir>/node_modules/@alienfast/build/config/jest/fileTransform.js',
},
transformIgnorePatterns: [
'<rootDir>/node_modules/(?!(lodash-es|@alienfast/ui)/).+\\.(mjs|js|jsx|ts|tsx)$',
],
testEnvironment: 'jsdom',
testURL: 'http://localhost',
globals: {
'ts-jest': {
tsConfigFile: 'tsconfig.test.json',
},
},
setupFiles: [
'<rootDir>/node_modules/@alienfast/build/config/polyfills.js',
'<rootDir>/src/config/jest/enzyme.ts',
'<rootDir>/src/config/jest/i18n.ts',
],
setupTestFrameworkScriptFile: '<rootDir>/node_modules/@alienfast/build/config/jest/testSetup.js',
mapCoverage: true,
collectCoverageFrom: ['src/**/*.{mjs,js,jsx,ts,tsx}'],
} |
I'm using If I'm understanding this correctly, this issue is being caused by I tried changing the script from: "test": "node --experimental-modules .bin/node_modules/react-scripts test" ...but I still ran into the same problem 🙁 I totally understand that because this is an issue with jest not transpiling correctly, it's probably out of scope for |
Any chance to delay the change to |
Seems this will be fixed in the next release. See #1801 |
This is fixed in react-apollo now but I still encountered it with the latest version of graphql.js. It looks like the real problem is in create-react-app though. See graphql/graphql-js#1248 and facebook/create-react-app#4085 |
If your project is built with Create React App and not ejected, https://github.com/facebook/create-react-app/releases/tag/v1.1.2 Otherwise you can apply a similar fix yourself in your project config. Cheers! |
Hi. Thanks you all for your replies. React-apollo update fix it for me. Thank you, SLedunois |
Hi guys.
I'm currently experimenting an issue with my new React project using React and GraphQL Apollo. Here is my stack :
The issue: When I run my tests, it seems that Apollo react client is not transpiled and throw tests :
My jest configuration is :
and my .babelrc is simply :
I found this issue jestjs/jest#3202 but it seems that the solution doesn't work with my project.
Can you help me?
Thank you,
SLedunois
The text was updated successfully, but these errors were encountered: