-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Update to Jest 24 #6278
Update to Jest 24 #6278
Changes from all commits
0083c25
48867b4
474286c
3ac353a
01e8934
0c443c3
f5399e4
53cfe41
2a73b46
c03227c
533d9bf
6e2715e
99a45ba
a78ba5c
e7b0f48
fa27338
File filter
Filter by extension
Conversations
Jump to
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 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? 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
setupTestsFile
above 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
setupFilesAfterEnv
like:rather than creating multiple file themselves.
IMO we should allow overriding
setupFilesAfterEnv
inpackage.json
if we really want to support this.