-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Coverage - provide a way to exclude lines or branches from coverage #7662
Comments
This is actually an essential feature for a production-ready test/coverage system, and one of the blockers (others being #4015, #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 |
It would be nice to be able to ignore certain files via bunfig. For example, I don't want to count repositories in my coverage. |
+1 |
Opened a PR to take care of this |
@abenjaminov the issue related to ignoring specific lines, blocks, etc. What I understand from the PR description, it is related to filtering files |
i also experienced the same thing, finally I was forced to add some configurations to [test]
coverage = true
coverageSkipTestFiles = true
coverageThreshold = { lines = 0.6, functions = 0.0 } |
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.
The text was updated successfully, but these errors were encountered: