c8 icon indicating copy to clipboard operation
c8 copied to clipboard

c8 reporting 100% coverage on function which throws

Open gear4s opened this issue 3 years ago • 5 comments

  • Version: v16.13.2
  • Platform: Darwin Aarons-MacBook-Pro.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_6

I have a project that I am refactoring, and c8 is reporting incorrect coverage for the files.

This is the coverage I have when I am trying to view test coverage: Screenshot 2022-01-28 at 17 28 32

The test that is being run: Screenshot 2022-01-28 at 17 29 21

If needed, this is the project: monorepo-coverage

gear4s avatar Jan 28 '22 15:01 gear4s

I recommend using environment variables to print the error log, these hints may help you solve the problem:

image

The command is NODE_DEBUG=c8 yarn test:unit:cover

bvanjoi avatar Jan 29 '22 09:01 bvanjoi

@bvanjoi unfortunately those do not affect my coverage results, and I would be concerned if they did - what I've done to fix those is just use --exclude dist but no change in coverage

gear4s avatar Jan 31 '22 09:01 gear4s

I've "fixed" it by placing the return statement in an else block. I don't think that should be the fix though, I believe that c8/v8 shouldn't report lines after a throw as being covered.

If there is some flag I should enable please let me know - I have tried a few other things already.

gear4s avatar Jan 31 '22 10:01 gear4s

This is most likely an underlying issue with v8 vs., c8. Will need to dig into raw output to actually see what's happening.

bcoe avatar Mar 23 '22 18:03 bcoe

let me know if there's anything more I can provide

gear4s avatar Mar 23 '22 18:03 gear4s