c8 icon indicating copy to clipboard operation
c8 copied to clipboard

Implicit `else` clause is not considered in coverage.

Open mikeal opened this issue 5 years ago • 2 comments

Consider the code below.

const x = 'asdf'
const fn = y => {
  if (typeof y !== 'object') {
    y = 'yup'
  }
  console.log(y)
}
fn(x)

The code branches on the if statement and the behavior changes if it’s false, but there isn’t an explicit else clause.

When running nyc this correctly says that only 50% of the branch coverage was detected, but in c8 it reports that 100% of the branch coverage was covered. The output can be found in this gist.

mikeal avatar Jun 12 '20 15:06 mikeal

@mikeal I owe you a corresponding bug on the Chrome issue tracker, haven't forgotten about this.

bcoe avatar Jun 17 '20 21:06 bcoe

I have opened a corresponding issue in v8 here:

https://bugs.chromium.org/p/v8/issues/detail?id=10627

bcoe avatar Jun 19 '20 22:06 bcoe