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
Vue components with no script breaks code coverage #671
Comments
We still have an issue with coverage reporting lines 12-17 as not being covered. |
Incorrect coverage is reported also when Without vueI18n // vite.config.js
export default defineConfig({
plugins: [vue()],
// ...
})
With vueI18n // vite.config.js
export default defineConfig({
plugins: [vue(), vueI18n()],
// ...
})
|
@1pm is this still a problem when testing with the latest version? |
For those watching this issue, it looks like the Vite Vue plugin that will be released with Vite v3 fixes it. See https://github.com/vitejs/vite/blob/plugin-vue@3.0.0-alpha.2/packages/plugin-vue/CHANGELOG.md#300-alpha2-2022-06-19 and particularly this commit vitejs/vite@ccfccec that fixes the sourcemaps for SFC components with no script I gave it a try on my projects, and the code coverage is now accurate |
Resolved by Vite 3 and @vitejs/plugin-vue 3 |
Describe the bug
Let's consider a valid Vue component like the following, with no
script
:with a unit test like:
The resulting code coverage is broken.
The result is:
Note that the file path is broken for all components, except the empty one.
But the empty one, has an issue with code coverage: it should be 100%.
When opening the HTML report for this component you get:
coverage/components/Empty.vue.html
:Reproduction
The component and test are available in https://github.com/cexbrayat/vitest/tree/repro/empty-vue-component-coverage
In the
examples/vue
directory, runpnpm coverage
.As a workaround, adding a
script
with just a comment fixes the code coverage:result:
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: