istanbul-js
Menu
Tutorials

tap coverage today: V8 collection and Istanbul reports

Use tap's own coverage controls instead of adding a second collector.

Source-file rows show line and branch measurements in an illustrative coverage report.
Current tap collection uses V8; inspect its report without assuming an older nyc wrapper recipe.

Why does an older tutorial mention nyc? Why can assertions pass while the run fails? Current tap documentation describes V8 collection and Istanbul report formats. Older Istanbul notes describe an earlier nyc arrangement. Follow the documentation for your installed tap.

Use the runner's reporting controls

For an already configured tap project, this script requests a terminal coverage report. Tap owns collection and its policy checks.

package.json (script fragment)

{
  "scripts": {
    "test": "tap",
    "coverage": "tap --coverage-report=text"
  }
}

The current guide describes incomplete or missing coverage as failure conditions. A successful assertion stream does not necessarily mean a successful process exit. Read the coverage result as well as the tests.

Set all intended limits

This YAML fragment illustrates a transitional policy, not a claim that these percentages establish correctness. Current tap documentation says an unspecified limit retains its default; one setting does not change the other measures.

.taprc (coverage fragment)

statements: 90
branches: 85
functions: 90
lines: 90

Configure tap directly rather than using nyc's check-coverage. For the general distinction between execution measures and a CI rule, read the threshold guide.

Use coverage maps to avoid incidental credit

Tap's coverage-map function maps a test path to the application files that test should cover. This lets a unit test be assessed against its intended module instead of gaining credit for unrelated imports. The current guide documents null for no collection from a particular test, and an empty array for coverage of loaded files.

Check the mapping against representative paths before applying it broadly. For TypeScript, map to original source filenames as the current tap guide describes.

Separate provider behavior from formatting

QuestionWhere to look
Which code was measured?Tap coverage settings and coverage maps.
Why did an ignore hint fail?The V8/c8 syntax documented by tap.
How do I change output?coverage-report or the report command.
Why did the process fail?Assertions, missing data and limits.

Tap can render Istanbul reports without collecting counters through Istanbul's source instrumenter. That distinction explains why a provider migration can change branch details even when the output looks familiar.

Primary sources

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