I am trying to pass along a configuration file to Jest in order to run tests only from a given directory.
According to documentation, you can use config.testPathDirs
: https://facebook.github.io/jest/docs/api.html#config-testpathdirs-array-string and you can call jest --config=<config-file>
.
Unfortunately the documentation doesn't include any description of how the configuration file should look like.
I tried both these options in a jest-config.js
file:
testPathDirs = ['coredata/src'];
and
config.testPathDirs(['coredata/src']);
and ran:
$ jest --config=jest-config.js
...but I get this type of error:
$ jest --config=jest-config.js Using Jest CLI v0.4.0 Failed with unexpected error. /Users/carles/dev/azazo/coredata/node_modules/jest-cli/src/jest.js:179 throw error; ^ SyntaxError: Unexpected token c at Object.parse (native) at /Users/carles/dev/azazo/coredata/node_modules/jest-cli/src/lib/utils.js:291:23 at _fulfilled (/Users/carles/dev/azazo/coredata/node_modules/jest-cli/node_modules/q/q.js:798:54) at self.promiseDispatch.done (/Users/carles/dev/azazo/coredata/node_modules/jest-cli/node_modules/q/q.js:827:30) at Promise.promise.promiseDispatch (/Users/carles/dev/azazo/coredata/node_modules/jest-cli/node_modules/q/q.js:760:13) at /Users/carles/dev/azazo/coredata/node_modules/jest-cli/node_modules/q/q.js:574:44 at flush (/Users/carles/dev/azazo/coredata/node_modules/jest-cli/node_modules/q/q.js:108:17) at process._tickCallback (node.js:419:13)
According to documentation, you can use config. testPathDirs : https://facebook.github.io/jest/docs/api.html#config-testpathdirs-array-string and you can call jest --config=<config-file> . Unfortunately the documentation doesn't include any description of how the configuration file should look like.
The directory where Jest should store its cached dependency information. Jest attempts to scan your dependency tree once (up-front) and cache it in order to ease some of the filesystem churn that needs to happen while running tests. This config option lets you customize where Jest stores that cache data on disk.
To create a test case in Jest we use the test() function. It takes a test name string and handler function as the first two arguments. The test() function can also be called under the alias - it() .
I figured out that the config file is JSON.
{ "testPathDirs": ["coredata/src"] }
Unfortunately I found nowhere in the documentation a hint about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With