-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Rerun Test Coverage Multiple Times Produce Different Coverage Results #1124
Comments
We require a link to a minimal repository demonstrating your issue. |
I created a small project that demonstrating this issue. The link: https://github.com/tilap35173/nyc-issues |
I have the same issue with nyc/ava. After some investigation, I identifie some troubes. {
"./nyc-issues/src/compareNumbers.ts": {
"path": "./nyc-issues/src/compareNumbers.ts",
"s": {
"0": 0,
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0,
"6": 0
},
...
},
...
} {
"./nyc-issues/src/compareNumbers.ts": {
"path": "./nyc-issues/src/compareNumbers.ts",
"s": {
"0": 1,
"1": 1,
"2": 1,
"3": 1,
"4": 0,
"5": 0,
"6": 0,
"7": 1,
"8": 28,
"9": 6,
"10": 22,
"11": 1,
"12": 21,
"13": 3,
"14": 18,
"15": 1
},
...
}
} We can see that istanbul doesn't identify the same list of statement. But why do we have two different mapping ? In {
"uuid": "d779d080-2dfb-40e1-bb91-2097dcc97f13",
"argv": [
"/Users/arthurweber/.nvm/versions/node/v8.15.1/bin/node",
"/Users/arthurweber/Sites/nyc-issues/node_modules/.bin/nyc",
"mocha"
],
...
} {
"uuid": "e8849878-fe5a-4639-8d58-81a8a26b69b7",
"argv": [
"/Users/arthurweber/.nvm/versions/node/v8.15.1/bin/node",
"/Users/arthurweber/Sites/nyc-issues/node_modules/mocha/bin/_mocha",
"test/**/*.spec.ts",
"--no-config",
"--no-package",
"--no-opts",
"--diff",
"--color",
"--extension",
"ts",
"--extension",
"js",
"--reporter",
"min",
"--require",
"ts-node/register",
"--ui",
"bdd",
"--slow",
"75",
"--timeout",
"2000"
],
...
} In addition, I try to remove In my opinion, nyc try to parse source files because of Maybe we need to pass some |
I may have a solution :
{
...
"require": ["ts-node/register"]
} |
@godu thanks for catching this. Having nyc perform the require for all transpilers is very important when you enable the nyc.all option. Without sources are not pre-proccessed by |
We could add this configuration as default in my opinion. |
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
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@coreyfarrell my hunch is this might be addressed by some of the work you've been doing around |
Yes I had expected the PR to close this issue, apparently I formatted incorrectly. This issue should be resolved in nyc@15. Any interested parties can follow #1104 for progress on the new release. |
@godu thank you so much! It works |
Link to bug demonstration repository
I've followed this link in nyc npm, since we use typescript
Run tests multiple times with test coverage enabled results in different results-
Expected Behavior
Observed Behavior
Half times is 85%
Half times is 68%
Interesting fact
When the percentage is higher, which is correct, I could see each code file coverage
But when the percentage is lower, which is incorrect, when I click each code file, some files instead of showing the code and coverage for each line, shows below message
Troubleshooting steps
cache: false
in my nyc configThis does nothing for me
Environment Information
The text was updated successfully, but these errors were encountered: