istanbul-js
Menu
Tutorials

Coverage tutorials: find the setup for your test runner

Start with the runner and runtime that already execute your tests.

A test run passes through coverage collection to produce a report.
Choose the runner and runtime first, then verify the collection boundary with one missed branch.

Do you need a nyc wrapper, or does the runner own collection? Are tests loading original source or a transformed build? Choose that boundary first, then verify the file list and a deliberately missed branch.

Choose your runner

Choose a transform or runtime guide

Make the first report explainable

Keep the ordinary test command passing before adding coverage. Select a small function, exercise one of two outcomes and inspect the report. Add the missing assertion and confirm the corresponding path changes. This checks collection more directly than an output directory's existence.

Use all, include and exclude to keep untouched source visible. A report limited to loaded modules can omit the code you most wanted to notice.

Move on to reports and policy

Once collection works, choose a reporter and then thresholds for the intended dataset. The advanced guides cover custom data handoffs and multiple suites.

Primary sources

Check official documentation against the tools installed in your project. These explanations and examples are independent.