Skip to content

CLI Reference

The code-coverage-report binary boots a local server that serves the coverage viewer.

Synopsis

bash
code-coverage-report [options] [-- <vitest-args...>]

Options

FlagDefaultDescription
--root, -r <path>current working directoryProject root used to discover the coverage file and serve sources from.
--coverage-file, -c <path><root>/coverage/coverage-final.jsonExplicit path to the Istanbul/V8 JSON coverage report.
--port, -p <number>5179First port to try. If busy, the next free port is used and logged.
--watch, -woffRun vitest run --watch --coverage --coverage.reporter=json and keep the viewer open.
--run-vitestoffRun vitest run --coverage --coverage.reporter=json once, then start the viewer.
--no-vitestonDo not run Vitest. Just serve the existing coverage JSON. This is the default.
--open / --no-open--openControl whether the browser auto-opens once the server is ready.
-- <args...>Everything after -- is forwarded to Vitest (file filters, options, etc.).
--help, -hPrint usage help.

Behavior change in v1.2.0

Since 1.2.0, code-coverage-report does not run Vitest by default. It only starts the viewer and reads existing coverage JSON. Use --run-vitest to run tests once, or --watch to run Vitest in watch mode.

Examples

Open the viewer for an existing report

bash
npx code-coverage-report

Run Vitest once, then open the viewer

bash
npx code-coverage-report --run-vitest

Watch mode (Vitest + viewer together)

bash
npx code-coverage-report --watch

Filter to a single spec while watching

bash
npx code-coverage-report --watch -- App.spec.ts

Point at a different project

bash
code-coverage-report --root ./apps/web

Use a custom coverage file path

bash
code-coverage-report --coverage-file ./artifacts/coverage/coverage-final.json

Pin to a specific port and skip auto-open

bash
code-coverage-report --port 5180 --no-open

How coverage is discovered

By default the CLI uses the current working directory as the project root and reads <root>/coverage/coverage-final.json. Both can be overridden with --root and --coverage-file.

The viewer also lazy-loads source files from disk, so per-line and per-branch overlays match your real source — keep --root pointing at the project that produced the coverage JSON.

Released under the GPL-3.0-or-later License.