🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

jest-coverage-thresholds-bumper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-coverage-thresholds-bumper

Tool for Jest testing library that automatically bumps up code coverage thresholds as real code coverage improves.

0.0.5
Source
npm
Version published
Weekly downloads
10K
-7.81%
Maintainers
1
Weekly downloads
 
Created
Source

jest-coverage-thresholds-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 without Ramda (it looks cool, but readability sucks IMO) and to add features I missed.

Tool supports jest.config.json, jest.config.js, and jest.config.ts configuration files, as well as jest section in package.json.

Value

Code coverage by tests may drop accidentally if you forget to cover new code with tests. It is easy to notice if your coverage thresholds are matching real coverage exactly. If you do have to decrease coverage then it has to be done explicitly and this fact will be more visible in pull requests.

Installation

Assuming that you already have Jest installed, call:

npm install -D jest-coverage-thresholds-bumper

Usage

  • Make sure that Jest has code coverage enabled and uses json-summary reporter. It is needed to produce coverage results for analysis.
  • Ensure that you have some threshold values specified (you can start with 0). jest-coverage-thresholds-bumper only updates existing values. Example:
// jest.config.js
...
  coverageThreshold: {
    global: {
      lines: 80,
      statements: 80,
      branches: 80,
      functions: 80,
    }
  }
...
  • Call jest-coverage-thresholds-bumper after running tests, for example:
// package.json
...
"scripts": {
    "test": "jest",
    "posttest": "jest-coverage-thresholds-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.

Options

Usage: jest-coverage-thresholds-bumper <command> [options]

Options:
  --coverage-summary-path  Path to Jest coverage results          [string] [default: "./coverage/coverage-summary.json"]
  --margin                 Minimal threshold increase                                              [number] [default: 0]
  --dry-run                Do analysis, but don't change any thresholds                                        [boolean]
  --silent                 No console output unless something goes wrong                                       [boolean]
  --help                   Show help                                                                           [boolean]
  --version                Show version number                                                                 [boolean]

Keywords

jest

FAQs

Package last updated on 12 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts