Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on coverage #37

Closed
ralphtheninja opened this issue Jul 19, 2018 · 2 comments
Closed

Question on coverage #37

ralphtheninja opened this issue Jul 19, 2018 · 2 comments

Comments

@ralphtheninja
Copy link
Member

So, given the current state we have the following results:

screenshot from 2018-07-19 12-08-46

I want to write a test that covers the following line

codec/index.js

Line 97 in 63d29a5

return function () {}

So I add the following test:

  t.test('no keys and no values not decoding', function (t) {
    var decoder = codec.createStreamDecoder({})
    t.equal(decoder(null, Buffer.from('hey')), undefined)
    t.equal(decoder(Buffer.from('hey')), undefined)
    t.end()
  })

The test works (passes) and covers the line correctly. However, for some reason nyc reports new lines in the code that aren't covered, which seems a bit weird to me. How can adding an extra test remove coverage? At worst it it's a bad test that doesn't add coverage, but it should never remove coverage imo. See below:

screenshot from 2018-07-19 12-15-23

What's going on here?

@vweevers
Copy link
Member

Perhaps those lines are partially covered, and your test changes the balance of how many times certain code branches are hit.

nyc report --reporter=html could tell you more.

@ralphtheninja
Copy link
Member Author

Also, there's seem to be a difference between red lines and yellow lines. Not sure what the color coding here means.

nyc report --reporter=html could tell you more.

Cool, will check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants