如果任何测试失败,Jest 是否以状态 1 退出是标准的?

Nic*_*Lee 11 node.js jestjs

当 Jest 中的测试失败时,它总是退出并抛出 npm 错误“errno 1”。我发现这是相当丑陋的,让它看起来相当令人震惊。这是 Jest 的标准吗?我更愿意只看到前 5 行。

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! applitoolsci@1.0.0 test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the applitoolsci@1.0.0 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
Run Code Online (Sandbox Code Playgroud)

Avi*_*Avi 10

实际上,这不是问题,当测试用例失败时,jest 以状态代码 1 退出。当任何测试或规范文件失败时,我们得到该错误,然后以状态 1( Exit status 1)退出,当它成功通过所有测试用例时,它以0退出是基于节点的通常行为CLItools.Check这个封闭的问题太多

但是您可以使用jest-html reporterjest-starepackage 来查找运行时失败的套件作为解决方法。