Skip to content

fix: negated project filtering (!) broken on browser projects#9978

Open
cyphercodes wants to merge 1 commit intovitest-dev:mainfrom
cyphercodes:fix-negated-project-filtering
Open

fix: negated project filtering (!) broken on browser projects#9978
cyphercodes wants to merge 1 commit intovitest-dev:mainfrom
cyphercodes:fix-negated-project-filtering

Conversation

@cyphercodes
Copy link
Copy Markdown

Description

When running vitest against a config with multiple vitest projects, filtering out browser projects with the negation/! operator did not work correctly.

Bug Report

Fixes #9977

Problem

When using --project !browser to exclude browser projects, the browser instances (like chromium, firefox, etc.) were still being included in the test run.

Root Cause

In resolveBrowserProjects, when the original project name didn't match the filter, it would fall through to filter individual instances. However, with negated patterns like !browser, the instance names (e.g., chromium) would match the pattern (since they're not browser), causing them to be incorrectly included.

Solution

Added a new method isProjectExcludedByNegatedPattern in the Vitest class that checks if a project name is explicitly excluded by any negated pattern (starting with !).

When resolving browser projects, if the original project name is excluded by a negated pattern, all its instances are now also excluded.

Changes

  • Added isProjectExcludedByNegatedPattern method to packages/vitest/src/node/core.ts
  • Updated resolveBrowserProjects in packages/vitest/src/node/projects/resolveProjects.ts to check for negated pattern exclusion before filtering instances

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

When using negated project filters like `--project !browser`, browser
instances were incorrectly included even when their parent project was
excluded.

The fix adds a new method `isProjectExcludedByNegatedPattern` that
checks if a project name matches any negated pattern (starting with !).
When resolving browser projects, if the original project name is
excluded by a negated pattern, all its instances are now also excluded.

Fixes vitest-dev#9977
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 26, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 848bc89
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69c572b6d0d4200008ff4f2c
😎 Deploy Preview https://deploy-preview-9978--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

Negated project filtering (!) broken on browser projects

1 participant