gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 00:48:17 24 4
gpt4 key购买 nike

当 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

最佳答案

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

但是你可以使用jest-html reporter 或者jest-stare包以查找哪个套件在作为解决方法运行时失败。

关于node.js - 如果任何测试失败,Jest 是否以状态 1 退出是标准的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55927777/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com