Skip to content

Implicit else clause is not considered in coverage. #227

@mikeal

Description

@mikeal

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions