antfu / unplugin-vue-components

📲 On-demand components auto importing for Vue

Home Page:https://www.npmjs.com/package/unplugin-vue-components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vite plugin breaks vitest coverage report

anatolsommer opened this issue · 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.)

probably caused by #219