5

In my test spec file, I am importing an es6 module using import statement. I am using jest test-runner and getting following error-

Cannot find module warnOnce from react-native-implementation.js

I edited ./e2e/config.json to add following configuration-

"preset": "react-native",
"transform": {
    "^.+\\.js$": "../node_modules/react-native/jest/preprocessor.js"
 }

But then I started getting errors- Cannot find module Platform from react-native-implementation.js

My .babelrc content-

{
  "presets": ["module:metro-react-native-babel-preset"],
  "plugins": [
    ["@babel/plugin-proposal-decorators", {"legacy": true}]
  ]
}

I tried replacing .babelrc with babel.config.js with similar content but got no luck. I was using mocha initially but switched to jest thinking that jest will have this support out of box.

Varun Kumar
  • 2,543
  • 1
  • 23
  • 22

0 Answers0