jest - Is there a way to check percentage of test coverage?

白昼怎懂夜的黑 提交于 2020-06-13 19:11:07

问题


I used following command to run my tests and get a coverage report:

jest --coverage

now I want to check whether percentage of coverage is more than 90% or not in my script file. what should I do ?


回答1:


You can use the coverageThreshold option in your Jest configuration:

https://jestjs.io/docs/en/configuration#coveragethreshold-object

{
  ...
  "jest": {
    "coverageThreshold": {
      "global": {
        "branches": 50,
        "functions": 50,
        "lines": 50,
        "statements": 50
      }
    }
  }
}


来源:https://stackoverflow.com/questions/40794031/jest-is-there-a-way-to-check-percentage-of-test-coverage

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