jest-coverage-ratchet

授权协议 MIT License
开发语言 PHP
所属分类 Web应用开发、 WebSocket开发包
软件类型 开源软件
地区 不详
投 递 者 公孙阳文
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

jest-coverage-ratchet

Raises jest's minimum coverage thresholds (per category) if current coverage is higher.

What does it do?

Lets say you have some jest coverage thresholds set in the package.json for your project at the following values:

{
  "branches": 30,
  "functions": 30,
  "lines": 30,
  "statements": 50,
}

then you get inspired one day and write lots of tests. Now your actual coverage summary might look like this:

{
  "branches": 50,
  "functions": 60,
  "lines": 77,
  "statements": 50,
}

Great �� Except you'd really like your accomplishment to set the new standard for test coverage in this project. jest-coverage-ratchet just does that automatically by looking at your current coverage summary, comparing it to your specified coverage thresholds, and updating the minimum for any threshold that is higher in the summary.

So given the previous values, running this script will update your coverage thresholds specified in the jest key of package.json to the following values:

{
  "branches": 50,
  "functions": 60,
  "lines": 77,
  "statements": 50,
}

Installation

Just add as a dev dependency to your project like

npm install --save-dev jest-coverage-ratchet

or

yarn add --dev jest-coverage-ratchet

I recommend then using the binary jest-coverage-ratchet as part of a prepush hook.

Assumptions

I know what happens when you assume, but jest-coverage-ratchet makes the following assumptions about your project.

  • jest has been run for project at least once with --coverage so that there is a valid file at the path ./coverage/coverage-summary.json (alternatively pass a path with --coverageSummaryPath of ./your/path/to/coverage-summary.json)
  • jest configuration object is present in the package.json that specifies at least:
    {
      // ...
      "jest": {
        "coverageReporters": [
          "json-summary"
        ],
        "coverageThreshold": {
          "global": {
            "branches": Number,
            "functions": Number,
            "lines": Number,
            "statements": Number,
          }
        }
      },
      // ...
    }

Should this tool support things like piping the coverage data in as an argument? Of course it should. If you want to build that and send a PR I will be all smiles �� . If not then you probably see me do it eventually.

Questions?

Just submit an issue or a PR, I'm no elitist.

 相关资料
  • Coverage 收集相关页面使用的 JavaScript 和 CSS 部分的信息。 使用 JavaScript 和 CSS 覆盖率来获取初始百分比的例子 执行代码: // 启用 JavaScript 和 CSS 覆盖 await Promise.all([ page.coverage.startJSCoverage(), page.coverage.startCSSCoverage()

  • Code coverage tells you which lines of script (or set of scripts) have been executed during a request. With this information you can for example find out how good your unit tests are. Xdebug's code co

  • CloudFormation Public Coverage Roadmap The AWS CloudFormation Public Coverage Roadmap Introduction This is a public roadmap focused on upcoming coverage support for CloudFormation. It is focused on co

  • Unified Code Coverage for Android A sample project showcase of how to merge the coverage data from both androidTest and test. Java Example Kotlin Example Java+Kotlin Example ============= Blog Post (e

  • This extension features one additional builder, the CoverageBuilder. class sphinx.ext.coverage.CoverageBuilder To use this builder, activate the coverage extension in your configuration file and give

  • This extension features one additional builder, the To use this builder, activate the coverage extension in your configuration file and give -b coverage on the command line. Todo Write this section. S