0.0.1 • Published 5 years ago

jest-coverage-bumper v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

jest-coverage-bumper

Build Status

Tool for Jest testing library that automatically bumps up code coverage thresholds as real code coverage improves. Inspired by https://github.com/Koleok/jest-coverage-ratchet, but I decided to re-write in more declarative style to add support for jest.config.js.

This tools should be used with Jest testing library. It automatically bumps up code coverage values in package.json or jest.config.json or jest.config.js files if test results have improved.

The value

Code coverage by tests ideally should only increase. Automatically bumping thresholds enforces this policy. If one developer added new tests and improved the coverage, another developer won't be able to commit changes that decrease the coverage. Any required decrease in code coverage will be visible in pull requests and people are more likely to notice bad practices.

How to install

Assuming that you already have Jest installed, call:

npm install -D jest-coverage-bumper

Usage

  1. Make sure that Jest has code coverage enabled and uses json-summary reporter. It is needed to produce a JSON file with coverage results.
  2. Call this method after running tests, for example using package.json scripts:
"scripts": {
    "test": "jest && jest-coverage-bumper"
}

When tool is called it finds coverage information, compares results with threshold values and bumps up values if results are higher. Note that only defined thresholds are bumped up - i.e. if no thresholds exists nothing will be bumped.

  • You may override path to coverage summary report using --coverageSummaryPath <path> command-line option. If no parameter specified tool will search for ./coverage/coverage-summary.json file.
  • You may specify custom path to Jest configuration file using --coverageThresholdsPath <path> command-line option. JSON and JS files are supported. If no parameter specified tool will look for jest.config.json and jest.config.js files first and if they are not available will try to find "jest" section in package.json.
0.0.1

5 years ago