istanbul-js
Menu

A first coverage report with Istanbul

A passing test and a coverage report answer different questions. Start by identifying which source files belong in the report.

This independent note occupies a blog URL recorded in the September 2019 archive inventory. The inventory identifies the URL and capture dates, but does not supply the original article text. The explanation below is newly written.

Follow one run from tests to report

Run the tests successfully before adding coverage collection. In a Node project using Mocha, nyc can wrap the test command. The resulting report shows which instrumented statements, functions and branches ran.

Check a file with a known missed branch. A high overall percentage can still leave that outcome untested. Also check whether the source scope includes files that the tests never import.

The Mocha walkthrough gives a worked setup. Use the file-scope guide to explain the denominator before setting thresholds.