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)
question from:
https://stackoverflow.com/questions/30027494/how-to-write-a-jest-configuration-file 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…