Inconsistent coverage levels between runs with "all"
See original GitHub issueLink to bug demonstration repository
- npm install
- npm run-script oneOff 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): https://github.com/istanbuljs/nyc/issues/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
- still occurrring when I put
cache: falsein my nyc config
Environment Information
System:
OS: Linux 4.18 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Memory: 557.58 MB / 7.64 GB
Binaries:
Node: 11.15.0 - /usr/bin/node
npm: 6.7.0 - /usr/bin/npm
npmPackages:
nyc: ^14.1.1 => 14.1.1
ts-node: ^8.1.0 => 8.1.0
typescript: ^3.4.5 => 3.4.5
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Inconsistencies between coverage summary of build and ...
runsettings file, I get 81.73% (Builds) and 76.59% (PR) (unit test project seems to be part of the coverage calculation) Downloading the code...
Read more >Inconsistent Coverage Report by NYC · Issue #537 - GitHub
Same issue on nyc v12.0.2 and QUnit v2.6.1. The coverage rates and uncovered line #s vary across runs when all is enabled.
Read more >Inconsistent coverage results using dotCover console runner ...
The coverage results are always 0% or change from run to run (even if there were no changes in the analyzed assemblies). Possible...
Read more >Inconsistent Code Coverage results - Salesforce Developers
When we attempt to deploy a new changeset to production (even one without new APEX code) the system runs though our test cases...
Read more >Jacoco coverage inconsistent on anonymous classes
The problem seems to be anonymous classes - they are sometimes not lining up with the test run - even though it's all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@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
.nyc_outputfirst.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).
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.