Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite plugin breaks vitest coverage report #333

Open
anatolsommer opened this issue Mar 21, 2022 · 1 comment
Open

Vite plugin breaks vitest coverage report #333

anatolsommer opened this issue Mar 21, 2022 · 1 comment

Comments

@anatolsommer
Copy link

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

@jeddi
Copy link

jeddi commented Dec 20, 2022

probably caused by #219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants