Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify module paths for Jest tests?

Tags:

reactjs

jestjs

It does not appear to respect the NODE_PATHS env variable, and instead just looks in the current directory.

like image 270
limscoder Avatar asked Aug 20 '14 18:08

limscoder


People also ask

Does Jest ignore Node_modules?

By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

How do I run a Jest test in a folder?

To run Jest tests only for current folder, we can run jest with the path of the folder with the tests we want to run. to run the tests in the dev/app folder given that the test script runs jest . We can also set the testPathPattern option to the folder with the tests we want to run. to run the tests in dev/app .


1 Answers

From Jest doc:

https://jestjs.io/docs/en/configuration

in package.json define:

"jest": {
  "modulePaths": [
    "<rootDir>/src/"
  ],
},
like image 125
Jesús Domínguez Avatar answered Sep 21 '22 16:09

Jesús Domínguez