Enable Coverage in Vitest

From the Vitest cheat sheet · Coverage · verified Nov 2026

Enable Coverage

Install a provider, run with --coverage, and choose which files are reported

typescript
// npm i -D @vitest/coverage-v8
// npx vitest run --coverage

// vitest.config.ts
export default defineConfig({
  test: {
    coverage: {
      provider: 'v8',                  // default; or 'istanbul'
      include: ['src/**/*.{ts,tsx}'],
    },
  },
})
📌 Without coverage.include only files your tests import are reported
⚡ v8 is faster and matches istanbul accuracy since Vitest 3.2
⚠️ v5 matches include/exclude relative to the root; recheck globs
🟢 Vitest offers to install the provider package on the first run
coveragev8istanbul

Continue with Vitest

Save the full cheat sheet or work through every related task.

More Vitest tasks

Back to the full Vitest cheat sheet