-
-
Notifications
You must be signed in to change notification settings - Fork 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 bugs when re-running same function #2456
Comments
Without reproduction setup it is hard to help, but could you try if setting |
Hi, I'm sorry I wasn't clear. Hard to get this info correct when trying to describe to someone coming into it cold. The reproduction above should be all that's needed I think. What I meant by re-run is that I have 3 tests there running Basically it ends up showing that I've only got partial coverage on that line. I've actually ended up noticing many issues with the partial coverage with vitest and c8/instanbul. Sometimes c8 is detecting a function returned as a conditional as well. I'm not sure if it'd help, but I can share my codecov URL and you'd see in many instances, the code within a simple https://app.codecov.io/github/components-web-app/cwa-nuxt-module/tree/feat%2Fmercure-and-api-docs/ This is the specific file results as you can see visually: This URL will change at some point as I'm implementing the tests on this feature branch which will be merged when work is complete on it. |
Here is a minimal reproduction: You'll see clover is produced with
So the This results in tools such as Additionally, using Edit:
I'm just not sure what the whole process is for the coverage functionality to try and trace these values and where it's all being set etc. I've never looked into the coverage side or this functionality yet and a bit snowed under just trying to write the tests and build a big application atm. So I'm unsure whether the issue is in |
@silverbackdan I haven't yet debugged this, but does this istanbul-reporter issue describe same problem? istanbuljs/istanbuljs#695 |
Thanks so much, yes, I think this will be an example of the same issue so I'll reference my reproduction there. |
Describe the bug
It appears when re-running tests on the same function, only the last run test result is kept on conditionals.
It seems to be the same with Istanbul and C8 so I'm not sure where the issue lies.
Reproduction
My middleware:
My tests:
Clover for the line:
comes out as:
If I run the test where the condition is false as the last test, then it shows as falsecount="1"
But as you can see, it was run multiple times so really the truecount and falsecount should equate to count
Any thoughts if this is a vitest bug or coverage providers?
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: