Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如果任何测试失败,Jest以状态1退出是否为标准?_Node.js_Jestjs - Fatal编程技术网

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

Node.js 如果任何测试失败,Jest以状态1退出是否为标准?,node.js,jestjs,Node.js,Jestjs,当一个测试在Jest中失败时,它总是抛出一个npm错误“errno 1”。我发现这是相当丑陋的,使它看起来相当令人担忧。这是开玩笑的标准吗?我更愿意只看前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

当一个测试在Jest中失败时,它总是抛出一个npm错误“errno 1”。我发现这是相当丑陋的,使它看起来相当令人担忧。这是开玩笑的标准吗?我更愿意只看前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

实际上,这不是问题,当测试用例失败时,jest以状态代码1退出。当任何测试或规范文件失败时,我们会得到该错误,然后它以状态1退出(
Exit status 1
),当它成功通过所有测试用例时,它以0退出。 这是基于节点的
CLI
工具的常见行为。也请检查此项


但您可以使用
jest-html-reporter
或包来查找哪个套件在作为解决方案运行时失败。

如果出现问题,任何进程都可以使用非零退出代码退出。考虑到解决方案是修复您的测试以使其通过,并且jest不会出错,因此您认为它是否丑陋应该无关紧要。深入研究jest运行时标志,看看是否可以对错误进行“假装成功”,但您不需要这样做:错误输出并不意味着看起来很好,它意味着向您显示出现了问题,因此您可以修复它们并使输出再次看起来很好。不,
npm
通常不会在测试失败时以状态1退出并创建调试日志。什么是
applitoolsci@1.0.0
?您是如何启动的
Jest