3

I have create an app with create-react-app.
I have set in .env my NODE_PATH=src/
All works fine when I launch react-script start but when I launch react-script test I have an error: import is not found. In my package.json :

"test": "jest --colors --coverage test"

Edit
It work fine with:

"jest": {
   "modulePaths": ["src/"],
   "testURL": "http://localhost",
   "jest": "^22.4.4"
}
dbc
  • 104,963
  • 20
  • 228
  • 340
D2DN
  • 59
  • 9

2 Answers2

0

You should execute your tests with

npm test

instead of directly using react-scripts here. Jest is automatically configured while using project created by create-react-app.

falinsky
  • 7,229
  • 3
  • 32
  • 56
0

If you want to directly call jest instead using the bundling set in react-scripts, you have to call:

"test": "./node_modules/jest/bin/jest.js --colors --coverage test"
Dez
  • 5,702
  • 8
  • 42
  • 51