-
Notifications
You must be signed in to change notification settings - Fork 79
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
Typescript extended classes show branch error #106
Comments
If this is an issue with our source-maps, we can potentially take a look into it for 2.1.5. |
Our team at SitePen hasn't run into this issue, but mostly because we avoid the ES6 Class syntax. Based on comments in the Istanbul ticket, it looks like a possible regression from TS 2.0.x to 2.1.x? |
Not really a regression - the behavior is intentional because classes need to possibly substitute values that have been explicitly returned from I guess the question is: if we adjusted our source maps in a certain manner, would remap-istanbul be able to effectively ignore the branch and treat it as one entity? |
Thanks for clarifying, my regression assumption was based on comments in the other issue. The normal approach for Istanbul to ignore a branch is to add a hint on what to skip, e.g. https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md , but I'm sure there's a better way as that feels hacky and may not really work here anyway. So I'm sure there's a way, just don't know what that is yet. We'll give it some thought after the holidays. |
Needed to work around issue with coverage when calling super(). See: gotwarlost/istanbul#690 microsoft/TypeScript#13455 SitePen/remap-istanbul#106
I have had a similar issue. I'm now convinced that it is best to simply stick to Related: |
This is due to the source-map actually mapping back to a specific call. Where other "helper" code gets rolled up and line coverage information gets merged, emitted code branches that are not present in the source code are not intelligently eliminated. A fix would be to more intelligently determine if branches can be mapped back logically to the source code and if they don't exist (they are only exist in emit land) then their coverage (or lack of coverage) should be dropped out. |
For the one using webpack and TypeScript configured to output ES5, |
Re my comment below, upgrading to jest-preset-angular 7.0.0-alpha-2 fixed this issue with setting to ES6, incase someone is facing the issue in angular. Changing the target to ES6, did not help for me. I am still having 50% branch coverage due to the super constructor. Is there any other solution? |
I'm not 100% sure if this is a remap issue or not. If not let me know what would be the responsible party.
The issue is when you have a class that extends another class and call
super()
the typescript compiler creates a branch that you cannot access which comes back as a branch failure and can dramatically decrease code coverage if there aren't many other branches in the file.Typescript example
Resulting Javascript
The semi-colon at the end of
super();
is highlighted with a "branch not tested" error.The text was updated successfully, but these errors were encountered: