如何检查控制台中的笑话覆盖率? [英] How to check jest coverage in console?
问题描述
我有一些玩笑测试,我可以通过
I have some jest tests and I can determine the coverage with
jest --coverage
另请参见 Jest的代码覆盖率
我自动在构建服务器(gitlab运行器)上执行测试,并且如果覆盖率低于以下范围,我希望测试失败一定的限制。
I automatically execute the tests on a build server (gitlab runner) and want that my tests fail if the coverage is below a certain limit.
在python中有一个标志-cov-fail-under
可与pytest一起使用,例如
In python there is a flag --cov-fail-under
that can be used with pytest, e.g.
pytest --cov src --cov-fail-under=90 --cov-report=term
不幸的是,我找不到对应的笑话选项。
Unfortunately, I could not find a corresponding option for jest.
=>建议检查总覆盖率的方法是什么?
=>What is the recommended way to check the total coverage?
我应该写一些额外的脚本来评估生成的json覆盖文件,还是有更简单的解决方案(例如特定的报告程序)使用?
Should I write some extra script to evaluate the generated json coverage file or is there an easier solution like a specific reporter to use?
推荐答案
未在CLI-Options中列出,但是有 coverageThreshold
,可在package.json或其他有趣的配置文件中使用:
Not listed under CLI-Options, but there is coverageThreshold
, which can be used in package.json or within an extra jest configuration file:
https://jestjs.io/docs/en/configuration#coveragethreshold-object
这篇关于如何检查控制台中的笑话覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!