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 786 forks source link

Code Coverage - Branch is reported as not covered #707

Open WilliamHolmes opened 8 years ago

WilliamHolmes commented 8 years ago

Istanbul reported is reporting this branch is not covered, however, it's clear that it is. Using typeof (underscore is not the issue).

image

You can see by the number of calls the branch is covered.

FYI: I ended up using _.isObject( )

morungos commented 7 years ago

Don't know if it's related, but I'm getting missed branches too. Apologies in advance for the CoffeeScript:

getPasswordHash = (password) ->
  new Promise (resolve, reject) ->
    bcrypt.genSalt 10, (err, salt) ->
      return reject(err) if err
      bcrypt.hash password, salt, (err, hash) ->
        return reject(err) if err
        resolve(hash)

I've used rewire to mock crypto and bcrypt and they're still marked as not taking the if path, even though I know they do because I've mocked them deliberately, and the promise is getting correctly rejected, which cannot happen unless an if branch is followed.