Skip to content
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

fix: Drop unneeded coverage data from nyc --all #456

Merged
merged 1 commit into from Aug 2, 2019
Merged

fix: Drop unneeded coverage data from nyc --all #456

merged 1 commit into from Aug 2, 2019

Conversation

coreyfarrell
Copy link
Member

Frequently users run nyc --all in a way that causes source files to be
transpiled for actual testing but not transpiled for --all. This
produces incompatible coverage data and inconsistantly wrong reporting.

The work around here is to drop coverage produced by --all for any
file where we have coverage produced by actual test runs. This ensures
that we prefer code that was transpiled in the way which tests actually
ran.

Fixes #123, #224, #260, #322, #413

Frequently users run `nyc --all` in a way that causes source files to be
transpiled for actual testing but not transpiled for `--all`.  This
produces incompatible coverage data and inconsistantly wrong reporting.

The work around here is to drop coverage produced by `--all` for any
file where we have coverage produced by actual test runs.  This ensures
that we prefer code that was transpiled in the way which tests actually
ran.

Fixes #123, #224, #260, #322, #413
@coreyfarrell coreyfarrell requested review from bcoe and JaKXz August 1, 2019 20:30
@coreyfarrell
Copy link
Member Author

See istanbuljs/nyc#1155 for nyc side of this.

Copy link
Member

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clever. we should definitely prefer the real coverage over the files we walked for all.

It's weird that we end up with incompatible coverage when using --all, but I can't think of a reason why we ever need to debug this fully?

@coreyfarrell
Copy link
Member Author

I believe it's because we merge coverage data before performing source-map remapping. So --all was producing coverage for the original sources and the test runs were producing coverage data for the transpiled sources. So it's really not unexpected if --all is not running the transpiler.

Copy link
Member

@JaKXz JaKXz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me at a high level... don't know enough of the details to give a more thorough review, sorry!

@coreyfarrell coreyfarrell merged commit f6bb0b4 into istanbuljs:master Aug 2, 2019
@coreyfarrell coreyfarrell deleted the coverage-drop-all branch August 2, 2019 16:37
@nshoes
Copy link

nshoes commented Aug 6, 2019

@coreyfarrell Do you know when this will be released for istanbul-lib-coverage?

@coreyfarrell
Copy link
Member Author

I don't have an exact date but it probably won't take long for a new alpha release of istanbul-lib-coverage. FYI this update will not apply to nyc 14.x. nyc 15.x is still being worked on, for progress on that you can follow istanbuljs/nyc#1104 (no ETA available).

vivek-freshworks pushed a commit to freshworks/istanbuljs that referenced this pull request Oct 26, 2023
Frequently users run `nyc --all` in a way that causes source files to be
transpiled for actual testing but not transpiled for `--all`.  This
produces incompatible coverage data and inconsistantly wrong reporting.

The work around here is to drop coverage produced by `--all` for any
file where we have coverage produced by actual test runs.  This ensures
that we prefer code that was transpiled in the way which tests actually
ran.

Fixes istanbuljs#123, istanbuljs#224, istanbuljs#260, istanbuljs#322, istanbuljs#413
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read property 'start' of undefined
4 participants