Ask questionsCouldn't find preset "module:metro-react-native-babel-preset" when running jest
<!-- Before creating an issue please make sure you are using the latest version of Metro, try re-installing your node_modules folder and run Metro once with
--reset-cache to see if that fixes the problem you are experiencing. -->
Do you want to request a feature or report a bug? bugreport
What is the current behavior?
I updated a react-native codebase from 0.56 to 0.57 and migrated from
"babel-preset-react-native": "^2.1.0" to the current version of
"metro-react-native-babel-preset". The app itself compiles and runs for iOS and android but all of the jest tests crash immediately on my mac and on our linux ci.
Test suite failed to run Couldn't find preset "module:metro-react-native-babel-preset" relative to directory "/Users/michaelknoch/dev/repos/JestCrashReproduction"
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can
yarn install and
I created this repo with react-native init. To run Jest we need at leat one file with pattern
So i ended up running this:
react-native init JestMetroCrash --version 0.57.0 && cd JestMetroCrash && touch App.test.js
Its worth to mention that the test suite also breaks when .babelrc with explicit
"presets": ["module:metro-react-native-babel-preset"] is provided.
What is the expected behavior? Jest should resolve the preset and transpile files correctly.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system. node v8.11.3 npm 6.4.1 metro latest release
Answer questions dsaharia
Hey @michaelknoch. I have the following versions:
"react": "16.5.1", "react-native": "^0.57.1", ... "@babel/cli": "^7.0.0", "@babel/core": "^7.0.0", "babel-core": "^7.0.0-bridge.0", "jest": "^23.6.0", "metro-react-native-babel-preset": "^0.45.0",
And it works just fine. Just had to change my
npm i -D babel-core@bridge).
Thanks a ton, man