-
-
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
How to ignore coverage data (instrumented code) from dependencies? #956
Comments
Hello @henriquemotaesteves 👋 You should be able to ignore specific files by customizing nyc's exclude rules: https://github.com/istanbuljs/nyc#excluding-files This can be done either in your package.json, in a .nycrc, or by passing additional exclude rules to the CLI using |
Hello @bcoe. I tested the proposed solution and it did not work. The location of the file is already ignored by default. The coverage data (exported cov_... functions) displayed by the report is injected indirectly when the dependency is imported by a file that can't be ignored because it is the target of the coverage process. The paths "Users/Dolan/Documents/docx/..." reported did not exist in my local disk. I did a test commenting the exported coverage data and this solution works, despite it is impractical. |
Struggling with this as well on a rollup-based project. No amount of futzing with the |
I'm having a similar issue with webpack (#953) where |
The merged pull request istanbuljs/istanbuljs#275 closes this issue, at least for me. @c0bra and @ssube, could you, please, confirm that is also true for your issues? |
@henriquemotaesteves I might be misunderstanding how to test this locally:
No difference. I'm probably missing something, yea? |
@c0bra, could you provide a coverage output (screenshot)? |
@henriquemotaesteves yup:
|
@c0bra, instead of define your exclude rule inside instrumentation:
excludes: ['**/node_modules/**'] |
@henriquemotaesteves same result. I removed the "nyc" config from package.json as well, just in case. |
@c0bra, what test runner are you using? Is your project public? I'm using |
@henriquemotaesteves I'm using ava, project is here: https://github.com/onboardist/ui Let me dig and see if I can figure out where it's not being set. |
@c0bra, I did not found any reference to |
@henriquemotaesteves well that stinks. I suppose there's no way around that if nyc is using lower-level access to istanbul. |
Followed the steps in #956 (comment) to link |
@c0bra the change made in the |
Yeah feel free to test out |
We've run into some issues with the updated code not honoring negated excludes. I need to address this before a new release can be made. I will follow-up here when I have more information / a new version to test. |
I'll try to give master a shot soon. |
@henriquemotaesteves looks great! thanks very much |
@c0bra Update, the PR I mentioned has been merged, so when you get a chance please test against the current |
@coreyfarrell Seems like it's reverted back to old behavior unless I've done something wrong: |
@c0bra this is with https://github.com/onboardist/ui? Do you run BTW I see a bunch of babel 6 dependencies, is this used? |
@coreyfarrell yes, that library. I ran The babel deps are probably leftovers from earlier. I removed and pruned them with no change. Also I've tried using
in package.json And lastly I tried blowing away node_modules just in case, but not joy. Perhaps I've misconfigured something? |
Following these steps I got the expected coverage results (node_modules were not listed). |
@coreyfarrell OK I tried a fresh checkout and it works, with those steps on my original checkout it's still providing the same result so clearly I've got something weird going on. I'll try to figure it out. Thanks for the fix! Update: got it. Not sure where I went wrong but it's working now! |
@c0bra Don't know but this is a completely different issue. Could you post a separate issue for that? Please be sure to link your repo to the new bug so we have all the information in one place. |
Link to bug demonstration repository.
https://github.com/henriquemotaesteves/nyc-bug-demo
Expected Behavior
How to ignore coverage data (instrumented code) from dependencies?
Observed Behavior
If a dependency is packed and published with coverage data (instrumented code), then these data are included in the coverage report.
Forensic Information
https://gist.github.com/henriquemotaesteves/2bcb39a27e1beda6a8a22c47805c8f95
[1] - https://github.com/webpack-contrib/istanbul-instrumenter-loader
[2] - https://github.com/dolanmiu/docx
The text was updated successfully, but these errors were encountered: