# istanbul-threshold-checker

> Utility module to check istanbul thresholds

Latest version **0.2.1** (published 2016-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install istanbul-threshold-checker
pnpm add istanbul-threshold-checker
yarn add istanbul-threshold-checker
bun add istanbul-threshold-checker
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2016-11-24 |
| First published | 2015-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Peter West |
| Maintainers | peterjwest |

## Links

- npm: https://www.npmjs.com/package/istanbul-threshold-checker
- Repository: https://github.com/peterjwest/istanbul-threshold-checker
- Issues: https://github.com/peterjwest/istanbul-threshold-checker/issues
- npm.io page: https://npm.io/package/istanbul-threshold-checker

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ~4.17.2
- [istanbul](https://npm.io/package/istanbul.md) ~0.4.5

## Recent versions

- 0.2.1 (latest) — 2016-11-24
- 0.2.0 — 2016-11-24
- 0.1.0 — 2015-04-28

## README

# Istanbul threshold checker
Checks an instanbul coverage report against thresholds

## Usage

Install with npm

    npm install istanbul-threshold-checker

Use by feeding a coverge report from istanbul:

    var collector = new require('istanbul').Collector();
    collector.add(coverageJsonObject);
    var coverage = collector.getFinalCoverage();

    var checker = require('istanbul-threshold-checker');
    var results = checker.checkFailures(thresholds, coverage);


## Thresholds

Thresholds can be specified in a variety of formats. Each threshold value can be specified as:

- A positive number - checks coverage meets this value as a percentage
- A negative number - checks there are no more coverage gaps than this number
- Any falsey value - skips checking this threshold

Thresholds can be checked across all files or against each file using `global` and `each` keys respectively:

    var thresholds = {
        global: {
            statements: 100,
            branches: 90,
            lines: 70,
            functions: -10
        },
        each: {
            statements: 0,
            branches: -20,
            lines: 60,
            functions: 100
        }
    };

You can exclude `global` or `each` if you only want to check global or per file coverage.

Each set of thresholds can also be a single value, which checks that value across all metrics:

    var thresholds = {
        global: 80,
        each: -10
    };


## Results

The checker returns results in the following format:

    [{
        type: 'lines',
        global: { failed: false, value: 90 },
        each: { failed: true, failures: ['/file/test.js'] }
    }, {
        type: 'statements',
        global: { failed: true, value: 50 },
        each: { failed: true, failures: ['/file/test2.js'] }
    }, {
        type: 'functions',
        global: { failed: true, value: -10 },
        each: { failed: true, failures: ['/file/test2.js'] }
    }, {
        type: 'branches',
        global: { failed: true, value: 66.67 },
        each: { failed: false, failures: [] }
    }]

---
_Source: https://npm.io/package/istanbul-threshold-checker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
