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
Feature Request: Instrument option to generate a baseline coverage file #1202
Comments
Could you test this with nyc 15 beta? In nyc 15 it should be possible to run |
I'm using the instrumented source as input to an e2e testing setup so I can't wrap I'm currently working with 15 beta, and |
For completeness the old |
Thanks for explaining I understand now. I'm open to such a feature as long as it's opt-in,
I would be interested in seeing an example of this. Running |
Cool, I'll try and put a PR together soon to add Regarding the flakiness, I've tested this again this morning and can confirm there is a difference in behaviour between establishing a baseline against raw code and pre-instrumented code. It'll take a little while to put together a demonstration repo as I've only noticed this on our production source so far. There seems to be two issues here,
I'm not too sure what I expect nyc to do when running this baseline coverage task against pre-instrumented source though. How do you expect it to behave? |
When |
I'll try and put together a demo project but it might take a little time as I'm seeing the issue on internal source that I can't share without some redaction. I'll drop it into a new issue as it's a little off topic in here. |
New issue for coverage differences #1208 |
Hi @coreyfarrell, I've got a couple of questions regarding this feature. I've got a rudimentary version of this going using the flag
My gut feeling is that the above answers should be yes, no, yes, yes. But I'll wait to hear back before I proceed. |
An alternative process I just thought of which might avoid the above issues:
This might be the best way to work baseline coverage into the normal process, I think would be easier to document? I wouldn't argue against |
I've been thinking a little bit about this feature and it seems to me that we really want is what This also simplifies the interface and the documentation. |
Problem
Currently when testing with files created by the standalone instrument command, if a file isn't hit it will not produce a coverage output file. This can lead to untouched files being excluded from the coverage report. Istanbul handled this by being able to produce a baseline coverage file with content similar to that produced by running
nyc --all=true /usr/bin/true
. When the baseline coverage file is included with test generated coverage files and fed to the reporter, files that aren't hit during tests are included in the report.In hindsight I think this was the problem being faced in #1044.
Proposal
Add an option to the instrument command, 'baseline', that will produce a baseline coverage output json file similar to that produced by running
nyc --all=true /usr/bin/true
.Workaround
You can generate a report that includes untouched files with:
nyc --all <options> /usr/bin/true
against the uninstrumented codeThe text was updated successfully, but these errors were encountered: