Open keverw opened 8 months ago
This is actually an essential feature for a production-ready test/coverage system, and one of the blockers (others being https://github.com/oven-sh/bun/issues/4015, https://github.com/oven-sh/bun/issues/7100) stopping me from switching to bun test.
Other popular test frameworks have this from v1, eg in vitest: https://vitest.dev/guide/coverage.html#ignoring-code (similar works in jest).
Hopefully this could be added to the roadmap. @Electroid
I just hit this problem too. For now, I have to reduce test coverage size, because what I'm testing dynamically creates modules using a BunPlugin.
It would be nice to be able to skip an entire module.
I'm migrating https://github.com/evmts/tevm-monorepo to vitest in future because of this issue
we can add a way to do this, particularly if the first implementation is just the next line
@Jarred-Sumner That won't do, I can't do an ignore for each line in a const enum that's bringing down coverage...
I would prefer to have something like /* coverage ignore start */
and /* coverage ignore end */
.
What is the problem this feature would solve?
Sometimes might be edge cases or rare that you might want to exclude or delegated to helper functions. For example I'm making a little CLI tool and made a very minimalist logger utility, process.exit I'd never actually call. So in my tests I just overwrote the .exit() method.
What is the feature you are proposing to solve the problem?
A way to add a comment similar to Istanbul.
For example:
/ istanbul ignore if /: ignores the next if statement. / istanbul ignore else /: ignores the else portion of an if statement. / istanbul ignore next /: ignores the next thing in the source-code ( functions, if statements, classes, you name it). So for example it can ignore the entire tree possibly. / istanbul ignore file /: ignores an entire source-file (this should be placed at the top of the file). / istanbul ignore else|if /: Ignores a “else if” - but it has to be at the top of the tree:
What alternatives have you considered?
Not really any ideas, my plan is to just keep working on my project and if there's a better way to do this, it'd be great otherwise something I can live with.