-
Notifications
You must be signed in to change notification settings - Fork 788
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
Include all source files in the report #275
Include all source files in the report #275
Conversation
Nicely done.
|
hidden behind the --include-all-sources flag After the coverage report has been built, manually instrument the files which have not been visited already, and add those to the report. When instrumenting the code manually, reset the count in the coverState object. FunctionDeclaration is given a visit number of 1 when instrumenting to compensate for function hoisting. We don't want that in this case, as the file was not actually loaded.
Thanks for the very thorough feedback! Totally agree with everything - I was a bit lazy when first sending this pull request, as I wanted to verify the solution before putting in too much work. :-)
I'm not sure about the way that I chose to warn the users when using the preload-sources switch - there might be a better place to do it. But it was the best place I could find / think of. |
@@ -24,6 +24,7 @@ function defaultConfig() { | |||
'complete-copy': false, | |||
'save-baseline': false, | |||
'baseline-file': './coverage/coverage-baseline.json', | |||
'include-all-sources': false, | |||
'preload-sources': false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the preload-sources
key from the default config safely? (that object is printed as help for the default configuration: istanbul help config
). I don't believe this will impact anything but this needs to be verified.
Excellent work! Could you attempt to remove the |
Removing preload-sources from the default config means that it wont be set in the object. I suspect that the reason is that no config option should not have a default value, which makes kind of sense. If this is unintended and not considered a feature, we could change that too, but I'd say that it's outside the scope of this pull request. So it's still present in the parsing of options passed to run-with-cover.js, to be propagated through to the configuration loader. And it's still present in the configuration loader, as it has to be there to be allowed to have effect. We might be able to golf down the number of "preload-sources" occurances in the code by moving the warning logic into run-with-cover.js - but it seems to be more proper to have that check in the configuration loading code, as that would catch all occurances of that flag - and not just those passed on the commandline to the I'll be more than willing to change it, if any of my conclusions are wrong. :-) |
I'm going to merge this and deal with that specific issue later. Thanks for all the hard work! |
…dedFilesInReport Include all source files in the report
No problem! It's a pleasure to be able to contribute a little back to a project that you use a lot :-) |
Available in v0.3.5 |
Yay! Thanks :-) |
Hi all! I need some help with this. I use babel and es6 syntax. I pass |
Is there an example somewhere of how to use this flag? I've tried
but I'm not seeing any difference in output… I'm using v0.3.13. Cheers! |
I wanted to have all my source files included in the report, no matter if they were tested or not, to provide a truthful picture of the actual coverage in the test suite, without doing weird hacks.
I tried using the
--preload-sources
option, but that had the unwanted side effect that it made it seem like you had quite a bit of extra coverage, which is the result of actuallyrequire
ing the code.So instead I tried implementing it by instrumenting the files which have not already been visited after the report has been built, and add those. The only workaround I needed to make was to reset the count of visits on FunctionDeclarations as those were given a count of one when instrumenting, to compensate for function hoisting.
The feature is hidden behind the
--include-all-sources
flag.I feel that this pull request covers the case of #142, in a simpler way than what you outlined in #142 (comment). Am I missing something?