-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
<template>
line is shown as not covered if v-if
used in component (4.6+, 5.0+)
#368
Comments
<template>
line is shown as not covered if v-if
used in component (4.6+)<template>
line is shown as not covered if v-if
used in component (4.6+, 5.x+)
<template>
line is shown as not covered if v-if
used in component (4.6+, 5.x+)<template>
line is shown as not covered if v-if
used in component (4.6+, 5.0+)
I made a new branch in the minrepro with today's date and the latest versions for all dependencies. Issue is still present: |
Issue still present with latest dependencies: |
Same here, still stuck on 4.5.2 all this time... |
Also unable to upgrade from 4.5.2 due to this coverage issue |
Now also unable to use Vite 6 as 4.5.2 requires Vite 5 |
It no longer works due to reuseAST, starting from version vue v3.4.3, vite-plugin-vue/packages/plugin-vue/src/template.ts Lines 214 to 226 in 8204fce
here is a workaround import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
+import * as CompilerDOM from '@vue/compiler-dom'
export default defineConfig({
plugins: [
vue({
+ template:{
+ compiler: CompilerDOM
+ }
})
],
test: {
environment: 'happy-dom',
globals: true,
coverage: {
exclude: [
'**/main.js'
]
}
}
});
|
I have another workaround which patches the compiler version so it skips ast re-use: vitest.config.js import { defineConfig } from 'vitest/config';
import Vue from '@vitejs/plugin-vue';
import * as compiler from 'vue/compiler-sfc';
export default defineConfig({
plugins: [
Vue({
compiler: { ...compiler, version: '3.4.2' },
}),
],
}); |
Related plugins
Describe the bug
In 4.5.2 and below components with
v-if
would have 100% test coverage, now with 4.6.0 and above they will report the first line of the Vue component (<template>
) as not being covered in tests.I've made the min-repro as simple as possible, it boils down to this:
Example:
Reproduction
https://github.com/TheJaredWilcurt/vite-plugin-vue-min-repro
Steps to reproduce
npm install
npm t
System Info
Tested on Node 20 and 21, Ubuntu 22.04 LTS and also GHA.
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: