Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

istanbul-threshold-checker

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul-threshold-checker

Utility module to check istanbul thresholds

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-10.8%
Maintainers
1
Weekly downloads
 
Created
Source

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: [] }
}]

FAQs

Package last updated on 24 Nov 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc