feat: exclude lines from processing#212
Conversation
| ## Excluding Lines | ||
|
|
||
| Sometimes you might find yourself wanting to exclude lines | ||
| in your application (for example, perhaps you have your unit tests inside of a file | ||
| you wish to check coverage of, but | ||
| you don't want to include the tests in the report). | ||
|
|
||
| To exclude lines, use the special comments `/* c8 exclude start */` and `/* c8 exclude stop */`. |
There was a problem hiding this comment.
How is this different from /* c8 ignore start */ + /* c8 ignore end */? I guess the ignore marks lines as covered, but this exclude would not include them in the report at all - like istanbul instrumented code does?
There was a problem hiding this comment.
Exactly. It excludes the lines from the report.
There was a problem hiding this comment.
Just my opinion but I think this will be complex for users. This would introduce a second set of ignore hint syntax where:
ignorewould mark lines as covered even if they are notexcludewould remove lines from coverage report - exactly asistanbulinstrumented coverage does for/* istanbul ignore ... */hints
And this new exclude hint does not cover all the same cases as ignore does.
I'm not sure why exactly the ignore syntax has been implemented so that it works differently when compared to istanbul instrumented code. I would rather see it work like your exclude hint here works so that it would completely remove the ignored parts from coverage report.
There was a problem hiding this comment.
I agree with you about the fact that ignore should work as exclude does.
Sometimes you want to exclude part of the code from the code coverage.
For example, perhaps you have your unit tests inside of a file (because you don't want to export private functions hence,
we test them locally).