mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
677 B
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'],
},
},
})