istanbul-js
Menu
Advanced reference

Choose an Istanbul reporter: HTML, LCOV, JSON or text

Choose the report format for the next person or tool that needs it.

Illustrative report rows compare line and branch coverage for individual source files.
HTML, LCOV, JSON and text present the same underlying measurements for different consumers.

Are you finding a missed branch or feeding a CI integration? Do you need raw counters or totals? Reporters format existing coverage. Switching from text to HTML does not execute another test or expand the measured file scope.

Match output to the job

ReporterUseUsual output
textPer-file log inspectionTerminal table
text-summaryAggregate totalsTerminal summary
htmlSource investigationcoverage/index.html
lcovonlyLCOV tool inputcoverage/lcov.info
lcovLCOV plus source browsingLCOV and HTML
jsonDetailed counterscoverage/coverage-final.json
json-summaryTotals for scriptscoverage/coverage-summary.json

A report-dir override changes the base directory. Summary JSON does not contain the individual counters and location maps carried by a detailed coverage object.

Generate or regenerate outputs

For a Mocha setup that nyc already measures correctly:

nyc --reporter=text --reporter=html --reporter=lcovonly mocha

If the raw files remain in .nyc_output, render another format without rerunning tests:

nyc report --reporter=html --reporter=json-summary

Keep the checkout and maps aligned with those files. Rendering old counters against changed source can produce highlights that no longer describe the tested code.

Inspect locations before colors

Select a file with a known untested outcome. Compare statements, functions and branches rather than substituting line coverage for all three. A line can run while an alternative on that line remains untested.

Watermarks control display bands. They are separate from thresholds that make check-coverage fail. Changing a watermark can change a color without changing a counter or CI policy.

Check the downstream paths

Before handing LCOV to another tool, inspect its source-file entries and compare them with that tool's checkout. An output file can exist while its paths are unusable downstream. Choose lcovonly for an LCOV-only integration and keep HTML for human review.

ProblemCheck
No report after testsCollected raw data and selected outputs.
No terminal summarytext or text-summary is selected.
Source cannot be mappedArtifact paths and source checkout.
Green report; failing gateWatermarks versus thresholds.

For custom reporting, continue with coverage maps and library APIs.

Primary sources

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