-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Coverage report is incorrect since 0.34.0 #3888
Comments
This sounds like #3251. In this case the A single file is tested in multiple environments. Vitest will pick source maps from the first result it finds. |
Any ideas how to setup a minimal reproduction for this case? Using whole |
Minimal reproduction case now at AriPerkkio@b1301eb. The custom Vite plugin transforms the source file differently depending on SSR/CSR. This intentionally causes different padding to source maps and messes the V8 results. Same should happen with Istanbul as well. On the left side is shown what coverage report looks like when same file is tested in Node and JSDOM. On the right side is what it looks like when it's tested only on one environment. The left one is clearly off. We'll need to tell coverage providers the vitest/packages/vitest/src/runtime/runners/index.ts Lines 63 to 65 in f4e6e99
Then they can use it in provider when picking the correct source map: vitest/packages/coverage-v8/src/provider.ts Line 217 in f4e6e99
This requires vitest/packages/vite-node/src/server.ts Lines 23 to 27 in f4e6e99
Currently |
I also want to point out that it might not have it if tests were running using browser. I remember that it would throw an error before, but currently, it just runs it with empty coverage. |
Describe the bug
When multiple environments are used, it seems like this affects how coverage is computed.
I've also noticed that the coverage report is different on my machine vs CI.
Please check this branch: adazzle/react-data-grid#3298
The coverage dropped significantly
In
test/ssr.test.tsx
, if I skip the test, the coverage INCREASES:Again in
test/ssr.test.tsx
, if I skip the test AND remove// @vitest-environment node
, the coverage INCREASES further, back to normal levels:It seems like Vitest 0.34 does not like multiple environments. 🤔
Reproduction
npm i
npm t -- --coverage
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: