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"
}
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
.
如果你想直接调用jest
而不是使用react-scripts
中的捆绑集,你必须调用:
"test": "./node_modules/jest/bin/jest.js --colors --coverage test"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.