Hello,
When I run in terminal "jest --verbose --coverage --noStackTrace", everything is okay.
I have npm scripts In packages.json:
{
...
"scripts": {
"test": "jest --noStackTrace",
"coverage": "jest --verbose --coverage --noStackTrace --no-cache",
"run": "webpack-dev-server --history-api-fallback"
},
...
}
And if I run 'npm run coverage' I get error:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'coverage' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'precoverage', 'coverage', 'postcoverage' ]
5 info lifecycle [email protected]~precoverage: [email protected]
6 silly lifecycle [email protected]~precoverage: no script for precoverage, continuing
7 info lifecycle [email protected]~coverage: [email protected]
8 verbose lifecycle [email protected]~coverage: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~coverage: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/SVITY/www/travel/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin
10 verbose lifecycle [email protected]~coverage: CWD: /Users/SVITY/www/travel
11 silly lifecycle [email protected]~coverage: Args: [ '-c', 'jest --coverage' ]
12 silly lifecycle [email protected]~coverage: Returned: code: 1 signal: null
13 info lifecycle [email protected]~coverage: Failed to exec coverage script
14 verbose stack Error: [email protected] coverage: `jest --coverage`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:877:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd /Users/SVITY/www/travel
17 error Darwin 16.0.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "coverage"
19 error node v6.7.0
20 error npm v3.10.8
21 error code ELIFECYCLE
22 error [email protected] coverage: `jest --coverage`
22 error Exit status 1
23 error Failed at the [email protected] coverage script 'jest --coverage'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the travel package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error jest --coverage
23 error You can get information on how to open an issue for this project with:
23 error npm bugs travel
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls travel
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
Which version of Jest (jest -v
) are you using globally and which one is defined in your package.json
?
Global and local versions are the same
This seems like an npm problem, not a Jest problem.
Just for the record... Not reaching the coverage threshold makes jest to exit with "Exit status 1" which is ignored when running directly on console but not with an npm script, which is expected. Two options, run your script with jest --coverage || true
or keep working on your tests :)
Not clear about why everyone is ok with @roboli comment.
"Not reaching the coverage threshold makes jest to exit with "Exit status 1" -> is not this desired behavior? I mean, why you define a coverage threshold for? -> To be sure your test suite fails if you do not reach that coverage.
I am facing the same problem, Jest is exiting with status 1, but in my case, I am reaching the coverage threshold, I am confused why this is happening, wasting too much time on this
Most helpful comment
Just for the record... Not reaching the coverage threshold makes jest to exit with "Exit status 1" which is ignored when running directly on console but not with an npm script, which is expected. Two options, run your script with
jest --coverage || true
or keep working on your tests :)