Vite plugin breaks vitest coverage report
anatolsommer opened this issue · comments
Anatol Sommer commented
As soon as the Vite plugin is used, all components (Vue 3 SFC) are marked as 100% covered.
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
export default defineConfig({
plugins: [vue(), Components()],
test: {
global: true,
environment: 'happy-dom'
}
})
npx vitest run --coverage
:
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
App.vue | 100 | 100 | 100 | 100 |
----------|---------|----------|---------|---------|-------------------
Once I remove Components()
from plugins:
coverage works fine again:
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 88.23 | 100 | 0 | 88.23 |
App.vue | 88.23 | 100 | 0 | 88.23 | 9-10
----------|---------|----------|---------|---------|-------------------
I could provide a minimal example but this applies to everything using vite and vitest so it should be very easy to reproduce. (It makes no difference if there are resolvers included or not.)
Aymen jeddi commented
probably caused by #219