bcoe / bcoe/c8

Implicit `else` clause is not considered in coverage.

Open
#227 2 comments 4 reactions 0 assignees View on GitHub
feature-request v8
Dominant language
JavaScript
Stars
2.1k
Forks
99
PR merge metrics
No merged PRs in 30d

Description

Consider the code below.

```js
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](https://gist.github.com/mikeal/60aea513165c35ac438f6a35f0727a75).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.