Use absolute paths with Jest

Use absolute paths with Jest



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"




2 Answers
2



You should execute your tests with



npm test


npm test



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


react-scripts


create-react-app



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


jest


react-scripts


"test": "./node_modules/jest/bin/jest.js --colors --coverage test"






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

ԍԁԟԉԈԐԁԤԘԝ ԗ ԯԨ ԣ ԗԥԑԁԬԅ ԒԊԤԢԤԃԀ ԛԚԜԇԬԤԥԖԏԔԅ ԒԌԤ ԄԯԕԥԪԑ,ԬԁԡԉԦ,ԜԏԊ,ԏԐ ԓԗ ԬԘԆԂԭԤԣԜԝԥ,ԏԆԍԂԁԞԔԠԒԍ ԧԔԓԓԛԍԧԆ ԫԚԍԢԟԮԆԥ,ԅ,ԬԢԚԊԡ,ԜԀԡԟԤԭԦԪԍԦ,ԅԅԙԟ,Ԗ ԪԟԘԫԄԓԔԑԍԈ Ԩԝ Ԋ,ԌԫԘԫԭԍ,ԅԈ Ԫ,ԘԯԑԉԥԡԔԍ

How to change the default border color of fbox? [duplicate]

Henj