-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 cleanOnRerun: false
causes crash
#5521
Comments
The vitest/packages/coverage-v8/src/provider.ts Lines 119 to 122 in 04b234d
|
For now we can add a fix that prevents the crash. But I'm starting to think that we should remove whole |
That was what I was trying to do. In some cases, the coverage outputted only shows the file you most recently changed. I wanted it to preserve the coverage of the other files too. |
Showing coverage results from earlier test runs will be difficult and Vitest is unable to do that reliably. The reports from earlier runs can be completely off if some of those files or their test files were changed in between.
The |
If the source file or test is changed, shouldn't it be able to just re-generate the relevant coverage files? It should be able to just leave the coverage records for files that are unrelated to the change. |
Yep, that's exactly how it works. It re-generates the relevant coverage files and leaves the other ones as is. The re-generated parts will be merged with old ones. Lines that should show 1x hits will show 2x and so on. |
Is there another option that regenerates relevant files but replaces the old results? So it'll still leave results for unchanged files but won't have duplicate results for the changed ones. |
I think the only way to achieve that would be for us to store coverage per test file, and then generate the new report by merging all of them every time the test reruns. But this is extremely memory-consuming, I would imagine. |
Got it. That is what I was expecting to happen with |
I guess we could use the vitest/packages/vitest/src/runtime/runners/index.ts Lines 70 to 77 in c84113f
... as cache keys in here vitest/packages/coverage-v8/src/provider.ts Lines 133 to 137 in c84113f
and use those to detect which results to invalidate from memory ( Without invalidating previous results we'll see this kind of issues. Uncovered branches are shown as covered as previous runs covered them: coverage-clean-on-rerun.mp4 |
Describe the bug
When setting
coverage.cleanOnRerun
to false, saving a file will cause the CLI to crash withError: ENOENT: no such file or directory, open '/path/to/repo/coverage/.tmp/coverage-[num].json'
.Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-7cu7ag?file=vite.config.ts
src/basic.ts
. The CLI will crash with the error above.If it doesn't crash, just wait for the coverage output again and try making another change.
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: