Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it standard for Jest to exit with a status 1 if any test fails?

Tags:

node.js

jestjs

When a test fails within Jest it always exits throwing an npm error "errno 1". I find this is be rather ugly and makes it seem rather alarming. Is this standard for Jest? I would much prefer to just see the first 5 lines.

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 failed, 3 passed, 4 total
Snapshots:   0 total
Time:        41.881s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nicklee/.npm/_logs/2019-04-30T19_33_00_584Z-debug.log
like image 914
Nick Lee Avatar asked Apr 30 '19 19:04

Nick Lee


1 Answers

Actually, it's not an issue, jest exits with status code 1 when the test case failed.We get that error when the any test or spec file fails then it exits with status 1(Exit status 1) and when it successfully passed the all test cases then it exits with 0. That is usual behavior of node based CLI tools.Check this closed issue too

But you can use jest-html reporter or jest-stare package to find which suite failed while running as a workaround.

like image 145
Avinash Singh Avatar answered Oct 20 '22 10:10

Avinash Singh