-
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
calling method on super: branch not covered #690
Comments
I can workaround to get 100% coverage by doing the following: export default class MyComponent extends Component {
constructor() {
super();
this.superLink = super.link();
}
link(name, Constructor) {
this.superLink(name, Constructor);
}
} class AnotherComponent extends Component {}
describe("MyComponent", () => {
it("should be covered", () => {
const myComponent = new MyComponent();
myComponent.link("anotherComponent", AnotherComponent);
});
}); |
this is reproducible for me on any call to |
is reproducible for me as well v 1.1.0-alpha.1. Marks opening bracket of each constructor where i call super as not covered branch |
Just called |
Having this problem too. I have to use the |
I've just got import React, { Component } from 'react'
export default class Main extends Component {
constructor(props) {
super(props)
this.state = {
counter: 0
}
}
render() {
{this.state.counter}
}
} And I get a notice that my constructor branch is not being covered and so then a less than 100% score on my branches. Is this related? |
That is the issue we're all complaining about, I believe. |
any news on a fix for this? I'm running into the same problem. Can't get my coverage to 100% as a result. :/ |
not as far as I know, just put down your expected coverage to what you get with this issue. that's what I am doing. |
I also did not find workaround for this. Thus I moved to nyc(which uses istanbul under cover) with babel and now everything is calculated correctly. |
Another option is to put |
Found the same issue, what is exactly generating this problem ? Some ES6 compatibility ? I'm working with React and that's a very common airbnb pattern. |
Found a workaround for the above problem I posted that doesn't anger the AirBnB lint gods (i.e. the react/sort-comp rule): It seems that adding the |
Nice find @owenDods ! I remember also running into that issue and just scrapping the static method entirely. |
Yeah @brandonsturgeon, I almost did the same. But I didn't want to alter my code because of a coverage bug! It was a matter of principle! |
I've been using On another machine, where |
OK, some more details: This doesn't happen with [email protected], but it does with [email protected] For this code:
In 2.1.4
Whereas 2.0.3 emits:
So it seems that this is caused by a change to how typescript emits. |
I believe that this one is for typescript to fix. Cast your vote and opinions: microsoft/TypeScript#13455 |
Needed to work around issue with coverage when calling super(). See: gotwarlost/istanbul#690 microsoft/TypeScript#13455 SitePen/remap-istanbul#106
I'm now convinced that it is best to simply stick to Related: |
WorkaroundAs a workaround I found the special comment If you place after your class, the constructor gets ignored. Has to be exactly after the brace, do not break lines. Example
Generates
Which ignores this line To ignore super
If you have generics and/or With those hacks I got 100% coverage. |
I got the same issue as |
For the one using webpack and TypeScript configured to output ES5, |
Got the same issue. Workaround works. |
I ran into the same problem running React with babel, webpack and karma. What solved it was switching from |
By installing |
Using |
The bug is still there in version |
Ignoring it works, but that doesn't really solve the problem. |
see gotwarlost/istanbul#690 for details
Any news about this? |
Just ran into this and found that removing the semicolon after raised coverage back to 100% ... at least until prettier put it back :/ |
You can replace this: |
I can confirm this is still an issue |
This is still an issue..! |
you are moving problem from that line to constructor |
thats good but what if I don`t want to write superlink, or just imagine if I have 50 components |
I can confirm this is still an issue |
…new tokens (#789) * Expose mfa_token from the mfa_required error when getting new tokens * Ignore super calls from istanbul See: gotwarlost/istanbul#690 * Export MfaRequiredError Co-authored-by: Steve Hobbs <[email protected]>
The way I worked around this issue (sorry, I can't share the code) is using a mock (in my case, jasmine).
In my test:
|
This results in:
The text was updated successfully, but these errors were encountered: