Open WilliamHolmes opened 8 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.
Istanbul reported is reporting this branch is not covered, however, it's clear that it is. Using typeof (underscore is not the issue).
You can see by the number of calls the branch is covered.
FYI: I ended up using _.isObject( )