Generating native V8 coverage report for Vitest with Monocart coverage reports
npm i vitest-monocart-coverage -D
// vitest.config.js
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
include: ['test/*.test.js'],
coverage: {
enabled: true,
include: ['src/**'],
provider: 'custom',
customProviderModule: 'vitest-monocart-coverage'
}
}
});
See Vitest custom coverage provider
- mcr.config.js
- mcr.config.cjs
- mcr.config.mjs
- mcr.config.json
- mcr.config.ts
See config example mcr.config.js
// mcr.config.js
export default {
// logging: 'debug',
// provider: 'istanbul',
name: 'My Vitest Coverage Report',
reports: [
'console-details',
'v8'
],
lcov: true,
outputDir: 'coverage',
onEnd: (results) => {
console.log(`coverage report generated: ${results.reportPath}`);
}
};
See monocart-coverage-reports for more coverage options.