NPM 覆盖率阈值 - 设置

NPM coverage threshold - settings

我是 运行 npm 覆盖率测试,想设置覆盖率阈值。我可以知道怎么做吗???

我目前运行它是一个竹子计划,如下所示:-

cd ${bamboo.build.working.directory}/XXX
npm install react-scripts
npm run coverage

我想在此处添加覆盖率阈值。你能帮我解决这个问题吗??

谢谢。

您可以按照 create-react-app guide 进行覆盖配置,因为它在后台使用 react-scripts。来自文档:

The default Jest coverage configuration can be overridden by adding any of the following supported keys to a Jest config in your package.json.

基本上,在 package.json jest 属性 下添加配置,例如

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