开玩笑-有没有办法检查测试覆盖率? [英] jest - Is there a way to check percentage of test coverage?

查看:86
本文介绍了开玩笑-有没有办法检查测试覆盖率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令来运行测试并获得覆盖率报告:

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

jest --coverage

现在我要检查脚本文件中的覆盖率百分比是否大于90%.我该怎么办?

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

推荐答案

您可以在Jest配置中使用coverageThreshold选项:

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
      }
    }
  }
}

这篇关于开玩笑-有没有办法检查测试覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆