start-coverage v1.0.6
start-coverage
Code coverage tasks for Start. Uses istanbul by default, but is compatible with babel-istanbul, isparta, ibrik and so on.
Install
npm i -D start-coverage
Usage
The sequence of tasks is simple: "instrument" sources, run tests, report collected code coverage and then check result against the provided thresholds (optional).
import start from 'start';
import reporter from 'start-pretty-reporter';
import files from 'start-files';
import clean from 'start-clean';
import * as coverage from 'start-coverage';
import mocha from 'start-mocha';
export function coverage() {
return start(reporter())(
files('coverage/'),
clean(),
files('lib/**/*.js'),
coverage.instrument(),
files('test/**/*.js'),
mocha(),
coverage.report([ 'lcovonly', 'html', 'text-summary' ]),
coverage.thresholds({ functions: 100 })
);
}
Instrument tasks is rely on array of files, see documentation for details.
Arguments
instrument
coverage.instrument(istanbul, options)
istanbul
– istanbul-compatible coverage tool,require('istanbul')
by defaultoptions
– Instrumenter options,{ embedSource: true, noAutoWrap: true }
by default
report
coverage.report(reporters, dir)
reporters
–[ 'lcovonly', 'text-summary' ]
by defaultdir
– output directory,coverage/
by default
thresholds
coverage.thresholds(thresholds)
Same as istanbul check-coverage
command:
Checks the coverage of
statements
,functions
,branches
, andlines
against the provided thresholds. Positive thresholds are taken to be the minimum percentage required and negative numbers are taken to be the number of uncovered entities allowed.
Only defined keys will be processed:
{
statements: 100,
functions: -10
}