vitest/docs/guide/coverage.md
2022-07-15 00:28:28 +08:00

677 B

title
Coverage | Guide

Coverage

Vitest supports Native code coverage via c8. c8 is an optional peer dependency, to use the coverage feature you will need to install it first by:

npm i -D c8

Then you could get the coverage by passing the --coverage flag in CLI.

{
  "scripts": {
    "test": "vitest",
    "coverage": "vitest run --coverage"
  }
}

To configure it, set test.coverage options in your config file:

// vite.config.ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    coverage: {
      reporter: ['text', 'json', 'html'],
    },
  },
})