-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Inconsistent coverage levels between runs with "all" #1113
Inconsistent coverage levels between runs with "all" #1113
Comments
Just compared a successful and failed run's json reporter output; the files are identical, but the coverage values in the terminal output still differ. |
Also compared the build output (/dist) of a successful and unsuccessful build; they are again identical. |
I can get 10 consistent passes by changing |
Very interesting! The issue here appears to be that istanbul is attempting to instrument both your original source typescript file, and your output For a reporter like I think this might be a configuration conflict between your tsconfig and jasmine.json config, though. Either your nyc+jasmine runtime should be in ts-node, and target only |
That makes sense, and explains why all would trigger it if it's actively looking for files to include and picking up ones it shouldn't. Going to have to play and see if I can fix it my end but doubtful. |
@elliot-nelson great digging. I've seen this issue for several years, and you're correct it seems to be a race condition between which JSON file is loaded from I would love to better document how to avoid this problem, as it's a frequent complaint for TypeScript users. If TypeScript is being built before running tests, It might also be worth looking at c8 which I've been finding works a bit better for my TypeScript libraries (the disclaimer being it doesn't work if TypeScript is being dynamically built in tests). |
Sometimes the coverage data produced by `nyc --all` is incompatible with the coverage data produced by actual test runs. This is generally due to configuration error but results in inconsistent coverage reports or in some cases causes `nyc report` to crash. The workaround is implemented in istanbul-lib-coverage to drop coverage data associated with `nyc --all` when coverage data from a test run is found. This commit tags the coverage data when appropriate so the coverage merge logic knows what to do. Fixes istanbuljs#1113, istanbuljs#1124, istanbuljs#1148
…#1155) * fix: Drop coverage produced by `nyc --all` for files that were tested Sometimes the coverage data produced by `nyc --all` is incompatible with the coverage data produced by actual test runs. This is generally due to configuration error but results in inconsistent coverage reports or in some cases causes `nyc report` to crash. The workaround is implemented in istanbul-lib-coverage to drop coverage data associated with `nyc --all` when coverage data from a test run is found. This commit tags the coverage data when appropriate so the coverage merge logic knows what to do. Fixes #1113, #1124, #1148
Link to bug demonstration repository
https://github.com/jameswilddev/nyc-repro
I've seen a few other issues reporting similar symptoms, but their fixes are things I'm already doing or are not applicable (different tools): #981
Expected Behavior
Repeated runs produce the same result (which is expected to be 100% here).
Observed Behavior
Repeated runs produce 92% or 100% coverage.
Troubleshooting steps
cache: false
in my nyc configEnvironment Information
The text was updated successfully, but these errors were encountered: