Skip to content

fix(bun): treat bun test arguments as path filters - #2165

Merged
webpro merged 3 commits into
webpro-nl:mainfrom
jakeleventhal:fix-bun-test-path-filters
Oct 19, 2026
Merged

webpro merged 3 commits into
webpro-nl:mainfrom
jakeleventhal:fix-bun-test-path-filters

Conversation

@jakeleventhal

Copy link
Copy Markdown
Contributor

bun test reads an argument as a path only when it starts with ./, ../ or /. Any other argument is a filter: Bun runs every test file whose path contains it. The Bun plugin treated those filters as literal paths, so a script like bun test .dom.test.tsx produced the entry .dom.test.tsx, matched nothing, and every test file it runs was reported as unused.

Filter arguments now become entry patterns: one ending in an extension matches paths ending with it (**/*.dom.test.tsx), and any other matches test files under a directory or with a file name containing it. Glob and ./-style path arguments keep their current behavior.

Added a bun9 fixture with an extension filter, a directory filter, and a test file neither matches, which is still reported. The test fails without the fix; the Bun plugin tests, the full suite (1,467 passing), lint, format and build pass.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@2165
npm i https://pkg.pr.new/@knip/language-server@2165
npm i https://pkg.pr.new/@knip/mcp@2165

commit: 10892cf

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request, Jake! I've added two small follow-up commits: bun test . now maps to the default test patterns, and dotted filters like .integration match by file name unless they end in a JS/TS extension.

@webpro
webpro merged commit 5f3a7fb into webpro-nl:main Oct 19, 2026
32 checks passed
@webpro

webpro commented Oct 19, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.42.1. See Release 6.42.1 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

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.

2 participants