public icon indicating copy to clipboard operation
public copied to clipboard

Not showing uncovered branch when `else` is missing

Open fvanwijk opened this issue 10 years ago • 10 comments

WallabyJS is not reporting uncovered else branches when there is only an if-branch. while Istanbul detects these uncovered branches.

This gives me no uncovered regions, where I expect to have Wallaby detect them also for missing else statements.

var someVar = true;
if (someVar) {
 // do something
}

Wallaby wallaby uncovered regions

Istanbul istanbul uncovered regions

fvanwijk avatar May 04 '15 08:05 fvanwijk

+1 I can't use wallaby exclusively without this.

dclarkNV avatar Jul 08 '16 18:07 dclarkNV

+1 Same for expressions like:

var a = options.a || defaults.a;

mprokopowicz avatar Sep 02 '16 20:09 mprokopowicz

@mprokopowicz Could you please provide some more details about your example? Wallaby supports those expressions and notifies if a part wasn't hit: i If you mean the case when both parts are hit (but result in false), then istanbul works the same way: screen shot 2016-09-03 at 10 18 10 am

ArtemGovorov avatar Sep 03 '16 00:09 ArtemGovorov

I'm disappointed to see that this was already requested years ago :( Would love to see this in the product.

oliversalzburg avatar Jan 22 '18 18:01 oliversalzburg

Why is this closed? Are you refusing to add the feature? I also want the option to turn off the ignoring of missing else statements.

chrissharp80 avatar Aug 14 '18 11:08 chrissharp80

Please note that this feature request has not been closed. We have plans to look into adding this functionality in the future but have no ETA we can provide at this point in time.

smcenlly avatar Aug 14 '18 23:08 smcenlly

I completely misread the reference as this issue being closed. Thanks, @smcenlly.

chrissharp80 avatar Aug 15 '18 10:08 chrissharp80

Any updates on this? Frankly, I'm lazy, and it's an extra step to have to check the Istanbul output just to make sure there's no untested else branches 😄

didehvar avatar Jan 15 '20 16:01 didehvar

@didehvar - we do not have any immediate plans to add missing else branches to code coverage calculations but we will take another look over the next month. There are a few items of complexity we need to address:

  • Must be opt-in; people are already familiar with our code-coverage calculations and do not always expect else blocks to be included in missing coverage
  • Need a good way to display missing else blocks in the editor as there is missing code that we can highlight

smcenlly avatar Jan 15 '20 22:01 smcenlly

Thanks for the response @smcenlly! Opt-in makes a lot of sense.

I'm guessing the if itself would have to be called out as missing coverage, though it doesn't look like there's any messages on hover so I'm not sure how it'd be clearly displayed. Uncovered code regions doesn't help either as there's nothing to highlight. Hopefully someone smarter can come up with something 😄

didehvar avatar Jan 24 '20 12:01 didehvar