I had project on 0.58.0 and upgraded to 0.59.1 and jest tests stopped working with an error
● Validation Error:
Configuration options testMatch and testRegex cannot be used together.
Configuration Documentation:
https://jestjs.io/docs/configuration.html
This is my jest configuration in package.json:
"jest": {
"preset": "react-native",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
"transformIgnorePatterns": [
"node_modules/(?!react-native|react-navigation)"
],
"setupFiles": [
"<rootDir>/__mocks__/mocks.js"
],
"globals": {
"window": {}
},
"testRegex": "(/__tests__/.*|\\.(test))\\.jsx?$"
}
Nowhere do I have testMatch.
Have 0.58 project and upgrade to 0.59.1
Tests to start running
React Native Environment Info:
System:
OS: Ubuntu 18.04.2 LTS
CPU: Intel® Core™ i5-4440 CPU @ 3.10GHz × 4
Memory: 15,6 GiB
Binaries:
Node: 10.10.0
npm: 6.4.1
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.4.1
npmPackages:
react: 16.8.4
react-native: 0.59.1
You're using react-native Jest preset, which includes testMatch, that's why you get the error. Please consider changing testRegex to testMatch (or just remove it) for now.
Btw, it seems like the testMatch config in RN preset
https://github.com/facebook/react-native/blob/02e8e531ddfd86e9abf7ef47fbf30445afeb37cf/jest-preset.js#L33-L36
pretty much aligns with the default from Jest 24:
https://github.com/facebook/jest/blob/c5fd7aae93764c13c259ae9a73846c10e84ae2a3/packages/jest-config/src/Defaults.ts#L70
So soon enough we should be able to get rid of this from the config.
To satisfy "working with TypeScript by default" constraint though, RN would need to require Jest 24+. @cpojer are we good to change it in 0.60 (I believe we are)?
@thymikee yeah, the latest Jest 24 should be part of RN on master.
Most helpful comment
You're using
react-nativeJest preset, which includestestMatch, that's why you get the error. Please consider changingtestRegextotestMatch(or just remove it) for now.Btw, it seems like the
testMatchconfig in RN presethttps://github.com/facebook/react-native/blob/02e8e531ddfd86e9abf7ef47fbf30445afeb37cf/jest-preset.js#L33-L36
pretty much aligns with the default from Jest 24:
https://github.com/facebook/jest/blob/c5fd7aae93764c13c259ae9a73846c10e84ae2a3/packages/jest-config/src/Defaults.ts#L70
So soon enough we should be able to get rid of this from the config.
To satisfy "working with TypeScript by default" constraint though, RN would need to require Jest 24+. @cpojer are we good to change it in 0.60 (I believe we are)?