KyleJune
KyleJune3y ago

How to exclude vendor directory from test coverage?

https://deno.land/manual@v1.25.4/testing/coverage Here it says by default it will exclude test\.(ts|tsx|mts|js|mjs|jsx|cjs|cts) and only include specifiers matching ^file:. If I wanted to keep the current behavior but also exclude my vendor directory how would I do that? Before this I tried excluding them from codecov by using the following codecov.yml in my .github directory but it didn't work and still shows coverage for my vendor directory.
comment: false
codecov:
require_ci_to_pass: true
coverage:
status:
project:
default:
informational: true
ignore:
- "vendor/**/*"
- "public/**/*"
comment: false
codecov:
require_ci_to_pass: true
coverage:
status:
project:
default:
informational: true
ignore:
- "vendor/**/*"
- "public/**/*"
Here is the documentation where it says how to ignore paths in codecov. I've also tried just doing vendor but that didn't work either. https://docs.codecov.com/docs/ignoring-paths Since I couldn't get codecov to ignore it correctly, I want to try getting deno coverage to instead.
Codecov
Ignoring Paths
You can use the top-level ignore: key to tell Codecov to ignore certain paths. Add a list of paths (folders or file names) to your codecov.yml file under the ignore key to exclude files from being collected by Codecov. Ignored files will be skipped during processing. The following are examples of di...
7 Replies
lucsoft
lucsoft3y ago
pretty sure codecov has nothing to do with denos coverage algo
KyleJune
KyleJune3y ago
yea, but codecov uploads the coverage files. If I can get deno to not generate coverage files for my vendor directory, I won't have this problem of codecov showing coverage for that directory.
lucsoft
lucsoft3y ago
did you try --exclude? else i think its impossible for vendored files as they are not remote you could upload you vendored files but this kinda defeats the purposes of vendored files
KyleJune
KyleJune3y ago
I want to but it says that would override the default. I want to add exclusions rather than replace the default exclusion/inclusions. The manual says the following.
These filters can be overridden using the --exclude and --include flags. A module specifier must match the include_regular expression and not match the exclude_ expression for it to be a part of the report.
These filters can be overridden using the --exclude and --include flags. A module specifier must match the include_regular expression and not match the exclude_ expression for it to be a part of the report.
I'm going to try deno coverage --exclude="(test\.(ts|tsx|mts|js|mjs|jsx|cjs|cts)|^vendor/.*|^public/.*)" --lcov cov > cov.lcov but it's a bit ugly. Would be great if the manual were updated to include examples. nope, looks like that didn't work.
lucsoft
lucsoft3y ago
no you need to do it from deno test not deno coverage i think
KyleJune
KyleJune3y ago
It says that about the coverage command though.
By default, deno coverage will exclude any files matching the regular expression test\.(ts|tsx|mts|js|mjs|jsx|cjs|cts) and only consider including specifiers matching the regular expression ^file: - ie. remote files will be excluded from coverage report.
By default, deno coverage will exclude any files matching the regular expression test\.(ts|tsx|mts|js|mjs|jsx|cjs|cts) and only consider including specifiers matching the regular expression ^file: - ie. remote files will be excluded from coverage report.
KyleJune
KyleJune3y ago
I went ahead and created an issue for this on denoland/manual. https://github.com/denoland/manual/issues/406
GitHub
Add example for excluding vendored dependency from deno coverage ...
The manual page for testing coverage mentioned that there are default inclusions/exclusions and that if you add either of those flags it would override those defaults. However it doesn't sh...