-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Exclude test files from coverage report #53508
Comments
Seems simple enough. The same logic for
|
I'm happy to work on this :-). |
Hey! Sorry for the delay, I've been out-of-town, but I'll begin work on this ASAP. |
Thanks @RedYetiDev! Shouldn't the default behaviour exclude test files themselves from the coverage report? I can't think of a reason anyone would ever want them included. |
Now that we have a way to configure the list of files, I agree that we should exclude the tests from the report. The issue in the past was that people could write tests in their source files. |
That shouldn't be too difficult. We can use the same list of file patterns to include with --test as ones to exclude for coverage |
The only "snag" is that glob patterns are used to find test files. Because that feature isn't stable, it'd cause an experimentalWarning |
We already use glob in the test runner. I think you need to avoid the public API to avoid the warning. |
The I'm just wondering if, speed wise, it's faster to get all the paths matching a glob, and check the path against that array, or check each glob using the Oh wait! The test runner will already have done that magic for us, I can reuse data! |
I'm keeping my lib files in src/main and my tests in src/test. I have my tests written in TS and run them with |
Is not usual to test the code coverage of test files. Fixes: nodejs#53508
Is not usual to test the code coverage of test files. Fixes: nodejs#53508
Is not usual to test the code coverage of test files. Fixes: nodejs#53508
@RedYetiDev Just created a PR with the "default exclude" behaviour: #55633 |
@pmarchini IMHO this issue is completed, the PR itself should be the discussion for the other exclusion rules. If you disagree, re-open |
@RedYetiDev, I reopened the issue since there's a related PR that will resolve this. Even though the PR is the right place for the implementation discussion, I think it might be better to keep this issue open until the PR lands. What do you think? |
SGTM, thanks for your insight :-) |
Is not usual to test the code coverage of test files. Fixes: nodejs#53508
Is not usual to test the code coverage of test files. Fixes: nodejs#53508
Is not usual to test the code coverage of test files. Fixes: nodejs#53508
What is the problem this feature will solve?
Hey folks! 👋🏼
I know that as by doc it's currently not possible to exclude specific files or directories from the coverage report.
The problem I face right now is that the coverage includes all of the test files.
For instance, if I have the following file:
and the test:
Once I run
node --experimental-test-coverage --test
I get:What is the feature you are proposing to solve the problem?
Ideally,
.test.*
should be excluded from the coverage reportWhat alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: