Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

istanbul-threshold-exit-code

1.0.3 • Public • Published

CLI tool that can be passed the path to the Istanbul JSON reporter's output, and will exit with a status code of 0 or 1, respectively, based on whether the reporter's output does or does not meet given thresholds.

The primary use case is to be run in CI. The main trigger for writing this was Jest's built-in coverage threshold checker not recognising remapped (e.g. to account for TypeScript) coverage. That issue has been solved with the release of Jest 20, though.

Usage

The recommended way to use this is to install it locally in your project, then to add the following to one of the scripts in your package.json:

istanbul-threshold-exit-code path/to/coverage.json [--global <global thresholds>] [--each <per-file thresholds>]

Arguments

--global

Thresholds that all files taken together should meet. Either a comma-separated list of (in that order) statement, branch, line and function coverage thresholds, or a single number for all of them. Threshold values can be any value supported by istanbul-threshold-checker.

Examples:

# require 100% statement and line coverage, but just 90% for branches and functions 
istanbul-threshold-exit-code path/to/coverage.json --global 100,90,100,90
 
# require 80% coverage for everything 
istanbul-threshold-exit-code path/to/coverage.json --global 100

--each

Thresholds that each individual file should meet. Either a comma-separated list of (in that order) statement, branch, line and function coverage thresholds, or a single number for all of them. Threshold values can be any value supported by istanbul-threshold-checker.

Examples:

# require 100% statement and line coverage, but just 90% for branches and functions 
istanbul-threshold-exit-code path/to/coverage.json --each 100,90,100,90
 
# require 80% coverage for everything 
istanbul-threshold-exit-code path/to/coverage.json --each 100

Keywords

none

Install

npm i istanbul-threshold-exit-code

DownloadsWeekly Downloads

40

Version

1.0.3

License

MIT

Last publish

Collaborators

  • avatar