How do I specify unit paths for Jest tests?
2 answers
Jest does not currently support NODE_PATH
module permissions in its code (for no reason other than that it just wasn't built).
We are currently tracking this issue: https://github.com/facebook/jest/issues/102
+1
source to share
Jest doesn't read NODE_PATH. In our project where we are using webpack, we ran into problems with alias
and moduleDirectories
. Jest did not resolve the path correctly. Therefore, we decided that like this: Suppose you want to import
import SomeComp from 'components/SomeComp';
which is located in /src/components/SomeComp/index.js
In package.json
define:
"jest": {
"moduleNameMapper": {
"/src/(.*)": "<rootDir>/src/$1"
}
},
0
source to share