c8
output coverage reports using Node.js' built in coverage
Last updated 6 years ago by bcoe .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install c8 
SYNC missed versions from official npm registry.

c8 - native V8 code-coverage

Build Status Coverage Status Conventional Commits

Code-coverage using Node.js' built in functionality that's compatible with Istanbul's reporters.

Like nyc, c8 just magically works:

npm i c8 -g
c8 node foo.js

The above example will output coverage metrics for foo.js.

c8 report

run c8 report to regenerate reports after c8 has already been run.

Checking coverage

c8 can fail tests if coverage falls below a threshold. After running your tests with c8, simply run:

c8 check-coverage --lines 95 --functions 95 --branches 95

c8 also accepts a --check-coverage shorthand, which can be used to both run tests and check that coverage falls within the threshold provided:

c8 --check-coverage --lines 100 npm test

The above check fails if coverage falls below 100%.

To check thresholds on a per-file basis run:

c8 check-coverage --lines 95 --per-file

Ignoring Uncovered Lines, Functions, and Blocks

Sometimes you might find yourself wanting to ignore uncovered portions of your codebase. For example, perhaps you run your tests on Linux, but there's some logic that only executes on Windows.

To ignore lines, blocks, and functions, use the special comment:

/* c8 ignore next */.

Ignoring the next element

const myVariable = 99
/* c8 ignore next */
if (process.platform === 'win32') console.info('hello world')

Ignoring the next N elements

const myVariable = 99
/* c8 ignore next 3 */
if (process.platform === 'win32') {
  console.info('hello world')
}

Ignoring a block on the current line

const myVariable = 99
const os = process.platform === 'darwin' ? 'OSXy' /* c8 ignore next */ : 'Windowsy' 

Supported Node.js Versions

c8 uses bleeding edge Node.js features, make sure you're running Node.js >= 10.12.0.

Contributing to c8

See the contributing guide here.

Current Tags

  • 7.0.0-alpha.0                                ...           experimental (5 years ago)
  • 10.1.2                                ...           latest (5 months ago)
  • 7.3.5-candidate.0                                ...           next (4 years ago)

88 Versions

  • 10.1.2                                ...           5 months ago
  • 10.1.1                                ...           5 months ago
  • 10.1.0                                ...           5 months ago
  • 10.0.0                                ...           5 months ago
  • 9.1.0                                ...           10 months ago
  • 9.0.0                                ...           10 months ago
  • 8.0.1                                ...           a year ago
  • 8.0.0                                ...           a year ago
  • 7.14.0                                ...           a year ago
  • 7.13.0                                ...           2 years ago
  • 7.12.0                                ...           2 years ago
  • 7.11.3                                ...           2 years ago
  • 7.11.2                                ...           3 years ago
  • 7.11.1                                ...           3 years ago
  • 7.11.0                                ...           3 years ago
  • 7.10.0                                ...           3 years ago
  • 7.9.0                                ...           3 years ago
  • 7.8.0                                ...           3 years ago
  • 7.7.3                                ...           3 years ago
  • 7.7.2                                ...           4 years ago
  • 7.7.1                                ...           4 years ago
  • 7.7.0                                ...           4 years ago
  • 7.6.0                                ...           4 years ago
  • 7.5.0                                ...           4 years ago
  • 7.4.0                                ...           4 years ago
  • 7.3.5                                ...           4 years ago
  • 7.3.5-candidate.0                                ...           4 years ago
  • 7.3.4                                ...           4 years ago
  • 7.3.3                                ...           4 years ago
  • 7.3.2                                ...           4 years ago
  • 7.3.1                                ...           4 years ago
  • 7.3.0                                ...           4 years ago
  • 7.2.1                                ...           4 years ago
  • 7.2.0                                ...           4 years ago
  • 7.2.0-beta.0                                ...           4 years ago
  • 7.1.2                                ...           5 years ago
  • 7.1.1                                ...           5 years ago
  • 7.1.1-beta.0                                ...           5 years ago
  • 7.1.0                                ...           5 years ago
  • 7.0.1                                ...           5 years ago
  • 7.0.0                                ...           5 years ago
  • 7.0.0-candidate.0                                ...           5 years ago
  • 7.0.0-beta.0                                ...           5 years ago
  • 7.0.0-alpha.0                                ...           5 years ago
  • 6.0.1                                ...           5 years ago
  • 6.0.0                                ...           5 years ago
  • 5.0.4                                ...           5 years ago
  • 5.0.3                                ...           5 years ago
  • 5.0.2                                ...           5 years ago
  • 5.0.1                                ...           5 years ago
  • 5.0.0                                ...           5 years ago
  • 4.1.5                                ...           6 years ago
  • 4.1.4                                ...           6 years ago
  • 4.1.3                                ...           6 years ago
  • 4.1.2                                ...           6 years ago
  • 4.1.1                                ...           6 years ago
  • 4.1.0                                ...           6 years ago
  • 4.1.0-candidate.0                                ...           6 years ago
  • 4.0.0                                ...           6 years ago
  • 4.0.0-beta.3                                ...           6 years ago
  • 4.0.0-beta.2                                ...           6 years ago
  • 4.0.0-beta.1                                ...           6 years ago
  • 4.0.0-candidate.0                                ...           6 years ago
  • 3.5.0                                ...           6 years ago
  • 3.4.0                                ...           6 years ago
  • 3.3.0                                ...           6 years ago
  • 3.3.0-candidate.3                                ...           6 years ago
  • 3.3.0-candidate.2                                ...           6 years ago
  • 3.3.0-candidate.1                                ...           6 years ago
  • 3.3.0-candidate.0                                ...           6 years ago
  • 3.2.1                                ...           6 years ago
  • 3.2.0                                ...           6 years ago
  • 3.1.0                                ...           6 years ago
  • 3.0.4-candidate.0                                ...           6 years ago
  • 3.0.3                                ...           6 years ago
  • 3.0.2                                ...           6 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 3.0.0-candidate.2                                ...           6 years ago
  • 3.0.0-candidate.1                                ...           6 years ago
  • 3.0.0-candidate.0                                ...           6 years ago
  • 3.0.0-alpha.4                                ...           7 years ago
  • 3.0.0-alpha.3                                ...           7 years ago
  • 3.0.0-alpha.1                                ...           7 years ago
  • 3.0.0-alpha.0                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Total 82
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (13)
Dev Dependencies (6)

© 2010 - cnpmjs.org x YWFE | Home | YWFE