unplugin-vue-components icon indicating copy to clipboard operation
unplugin-vue-components copied to clipboard

Vite plugin breaks vitest coverage report

Open anatolsommer opened this issue 2 years ago • 0 comments

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.)

anatolsommer avatar Mar 21 '22 13:03 anatolsommer