How to check jest coverage in console?

半城伤御伤魂 提交于 2020-03-21 06:54:38

问题


I have some jest tests and I can determine the coverage with

jest --coverage

Also see Code coverage for Jest

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.

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?

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?


回答1:


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



来源:https://stackoverflow.com/questions/60512167/how-to-check-jest-coverage-in-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!