I'm using Vitest in my project and I'm trying to obtain a coverage report from the Vitest UI. I've followed the steps from the docs, but I'm getting the error "Coverage enabled but missing html reporter" when hovering over the coverage icon.
I've set the html reporter in my vitest configuration, and have also set enabled=true, so why am I still unable to see the coverage report?
Here's my vitest configuration file:
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
enabled: true,
},
},
})
It turns out this was caused by incompatible vitest package versions. I fixed it by upgrading my vitest version to be the same as @vitest/coverage-v8 in my package.json.
Make sure that when you run npm install
no errors are produced regarding vitest packages.