use case

How to analyze a Vitest coverage report with LCOV

View Vitest test coverage from a lcov.info file to identify under-tested TypeScript files.

Vitest's built-in coverage (via @vitest/coverage-v8 or @vitest/coverage-istanbul) can generate LCOV output alongside its terminal summary. The LCOV file gives you per-file detail that the terminal summary omits. This guide shows how to configure Vitest to emit LCOV and how to view the results using the quickhelp.dev LCOV Coverage Viewer.

Step-by-step guide

  1. Configure Vitest LCOV reporter: In vitest.config.ts, set: coverage: { reporter: ['lcov', 'text'], reportsDirectory: 'coverage' }. Run vitest --coverage.
  2. Upload lcov.info: Find coverage/lcov.info in your project. Upload it to quickhelp.dev/lcov-viewer. All TypeScript source files appear with their coverage percentages.
  3. Prioritize test writing: Sort by branch coverage ascending to find the most under-tested files. Branch coverage reveals missing test cases for conditional logic better than line coverage alone.

Frequently asked questions

Should I use @vitest/coverage-v8 or coverage-istanbul?
V8 coverage uses the JavaScript engine's native instrumentation and is faster but less precise. Istanbul instruments your source code for more accurate branch data. For TypeScript projects, istanbul usually gives more meaningful branch coverage numbers.
Can I fail CI when coverage drops below a threshold?
Yes — use the API endpoint (POST /api/lcov-viewer) in your CI pipeline to parse lcov.info and extract the summary JSON, then assert on linesCoverage, functionsCoverage, or branchesCoverage.

Try it now

Use the LCOV Coverage Viewer to complete this task — free, no sign-up, runs in your browser.

Open LCOV Coverage Viewer

We use cookies to serve ads and measure traffic. Cookie policy · Privacy policy