Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 26.9k
Update to Jest 24#6278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Update to Jest 24 #6278
Changes from all commits
0083c2548867b4474286c3ac353a01e89340c443c3f5399e453cfe412a73b46c03227c533d9bf6e2715e99a45baa78ba5ce7b0f48fa27338File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -16,6 +16,6 @@ | ||
| "index.js" | ||
| ], | ||
| "devDependencies": { | ||
| "jest": "23.6.0" | ||
| "jest": "24.5.0" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -24,20 +24,13 @@ module.exports = (resolve, rootDir, isEjecting) => { | ||
| const config = { | ||
| collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'], | ||
| // TODO: this breaks Yarn PnP on eject. | ||
| // But we can't simply emit this because it'll be an absolute path. | ||
| // The proper fix is to write jest.config.js on eject instead of a package.json key. | ||
| // Then these can always stay as require.resolve()s. | ||
| resolver: isEjecting | ||
| ? 'jest-pnp-resolver' | ||
| : require.resolve('jest-pnp-resolver'), | ||
| setupFiles: [ | ||
| isEjecting | ||
| ? 'react-app-polyfill/jsdom' | ||
| : require.resolve('react-app-polyfill/jsdom'), | ||
| ], | ||
| setupTestFrameworkScriptFile: setupTestsFile, | ||
| setupFilesAfterEnv: setupTestsFile ? [setupTestsFile] : [], | ||
| testMatch: [ | ||
| '<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}', | ||
| '<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}', | ||
| @@ -77,6 +70,7 @@ module.exports = (resolve, rootDir, isEjecting) => { | ||
| 'collectCoverageFrom', | ||
| 'coverageReporters', | ||
| 'coverageThreshold', | ||
| 'extraGlobals', | ||
| 'globalSetup', | ||
| 'globalTeardown', | ||
| 'resetMocks', | ||
| @@ -94,13 +88,13 @@ module.exports = (resolve, rootDir, isEjecting) => { | ||
| const unsupportedKeys = Object.keys(overrides); | ||
| if (unsupportedKeys.length) { | ||
| const isOverridingSetupFile = | ||
| unsupportedKeys.indexOf('setupTestFrameworkScriptFile') > -1; | ||
| unsupportedKeys.indexOf('setupFilesAfterEnv') > -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hey @Loryman there is list of supported keys Can I ask you to add It drastically improves performance of jest image snapshot test jest docs: https://jestjs.io/docs/en/configuration#extraglobals-array-string Isssues: jestjs/jest#5163 ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @iansu Any thoughts on this? Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's probably okay to add that to the supported keys. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! | ||
| if (isOverridingSetupFile) { | ||
| console.error( | ||
| chalk.red( | ||
| 'We detected ' + | ||
| chalk.bold('setupTestFrameworkScriptFile') + | ||
| chalk.bold('setupFilesAfterEnv') + | ||
| ' in your package.json.\n\n' + | ||
| 'Remove it from Jest configuration, and put the initialization code in ' + | ||
| chalk.bold('src/setupTests.js') + | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rather than this here you modify the assignment of
setupTestsFileabove to potentially allow multiple files to be assigned:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can totally do this, although i think that most users would use
setupFilesAfterEnvlike:rather than creating multiple file themselves.
IMO we should allow overriding
setupFilesAfterEnvinpackage.jsonif we really want to support this.