Skip to content

fix(coverage): exclude linked/patched packages from coverage report#34834

Merged
bartlomieju merged 1 commit into
mainfrom
fix/coverage-exclude-patched-packages
Jun 5, 2026
Merged

fix(coverage): exclude linked/patched packages from coverage report#34834
bartlomieju merged 1 commit into
mainfrom
fix/coverage-exclude-patched-packages

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Running deno test --coverage in a project that uses the links (formerly
patch) feature included the linked package's files in the coverage report.
For example, a project linking @luca/flag saw an entry like
patch/jsr.io/@luca/flag/1.0.1/main.ts with low coverage, which also skewed
the "All files" totals.

Linked/patched packages are third-party dependencies that replace a registry
version, so they should be excluded from the user's coverage report the same way
npm packages already are. filter_coverages now drops any coverage entry whose
URL falls under one of the workspace's link folders, which it gets from
Workspace::link_folders().

Added a spec test under tests/specs/coverage/patched_package_excluded that
links a local @denotest/flag package, runs deno test --coverage, and asserts
the lcov report contains only the user's main.ts. The test was confirmed to
fail before the change (the linked flag/mod.ts appeared) and pass after.

Fixes #29391

Packages brought in via the "links" (formerly "patch") feature are
third-party dependencies replacing a registry version, so they should not
appear in the user's coverage report, the same way npm packages are
already excluded. Before this change, running "deno test --coverage" in a
project using "links" reported coverage for the linked package's files
(e.g. patch/jsr.io/@luca/flag/1.0.1/main.ts), skewing the totals.

filter_coverages now also drops any coverage entry whose URL is under one
of the workspace's link folders.

Fixes #29391
@bartlomieju
bartlomieju merged commit c6eaa57 into main Jun 5, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the fix/coverage-exclude-patched-packages branch June 5, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: coverage includes patched package

1 participant