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

Code coverage reports altered - 100% coverage not possible anymore #95

Closed
albertogasparin opened this issue Jan 26, 2016 · 9 comments · May be fixed by albertogasparin/babel-plugin-require-coverage#1

Comments

@albertogasparin
Copy link

babel-plugin-rewire instrumentation is not ignored by istanbul (and as a consequence it affects also isparta, nyc, etc). So, reports are wrong and it is no longer possible to get 100% code coverage, even if the source code gets properly tested.
The issue is even more accentuated when babel option retainLines: true is set.

I have created a clean test project to let you play around: babel-plugin-require-coverage

@culshaw
Copy link

culshaw commented Feb 29, 2016

I've had this problem using normal rewireify too. There is a solution in wrapping the rewireify lines with /* istanbul ignore next */ would bring the coverage back to reasonable levels (hopefully).

@culshaw
Copy link

culshaw commented Feb 29, 2016

@albertogasparin see pull request here: i-like-robots/rewireify#22

@albertogasparin
Copy link
Author

So it looks like this PR was proposing the right solution: #52
@speedskater, @dlmr and @TheSavior any chance to have this fixed?

@speedskater
Copy link
Owner

@albertogasparin From my point of view it will be considered. But we first of to ship a working version with babel 6 support. I hope this answer is not too disappointing for you.

@TheSavior
Copy link
Contributor

I still have my same concern. It seems like it shouldn't be the responsibility of this plugin to add specific code to support all other plugins. If we add comments to our code to ignore istanbul and another thing comes along, we shouldn't have to continuously modify this plugin.

As a possible solution to this, I could imagine another plugin that runs before this one that adds a comment to the beginning and end of the user's real code. That plugin and those comments could be specific to istanbul to ignore other things.

@speedskater
Copy link
Owner

@TheSavior what about a pluggable approach, Providing a hook, for generating comments on generated code? So it is the responsibility of the plugin using this hook to generate the correct comment.

@TheSavior
Copy link
Contributor

Hmm. I'm not familiar with babel plugins providing hooks to other babel plugins. Is that what you are proposing?

@culshaw
Copy link

culshaw commented Mar 4, 2016

@TheSavior I agree with you about how it isn't the plugins responsibility. It also feels very hacky to be squirting in comments defined by a user in a config file or as a hook for other plugins to latch onto.

The only way I know of which would negate the need for these comments is to process the files, write them to a location then load them with istanbul afterwards. I have that working but it is significantly slower.

@speedskater
Copy link
Owner

@culshaw sorry for the extremely long delay. I changed your sample project to use babel-plugin-istanbul and the resulting code coverage is 100% on all levels. Therefore I will close this issue for now. If this doesn't solve your problem please feel free to reopen this issue

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 a pull request may close this issue.

4 participants