/c8

output coverage reports using Node.js' built in coverage

Primary LanguageJavaScriptISC LicenseISC

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

Supported Node.js Versions

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

Goals of the Project

A fully functional code coverage solution using only V8's native coverage features and minimal user-land modules, so that we fit these constraints:

  • No parsing of JavaScript code.
  • No mucking with Node.js' runtime environment.

Contributing to c8

See the contributing guide here.