gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 787 forks source link

Coverage different beahaviour with different coding styles #857

Open saintplay opened 6 years ago

saintplay commented 6 years ago

I'm using Jest
Sorry if duplicated, but I found this behavior

if (this.popoverTo === 'right') {
  positionStyle = { left: 0 }
} else if (this.popoverTo === 'left') {
  positionStyle = { right: 0 }
}

Istanbul says } else if (this.popoverTo === 'left') { is not covered

But, if I make some changes to the coding styling

if (this.popoverTo === 'right') positionStyle = { left: 0 }
else if (this.popoverTo === 'left') positionStyle = { right: 0 }

I got 100% coverage, which is the correct report