fix: negated project filtering (!) broken on browser projects#9978
Open
cyphercodes wants to merge 1 commit intovitest-dev:mainfrom
Open
fix: negated project filtering (!) broken on browser projects#9978cyphercodes wants to merge 1 commit intovitest-dev:mainfrom
cyphercodes wants to merge 1 commit intovitest-dev:mainfrom
Conversation
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
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 !browserto exclude browser projects, the browser instances (likechromium,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 notbrowser), causing them to be incorrectly included.Solution
Added a new method
isProjectExcludedByNegatedPatternin 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
isProjectExcludedByNegatedPatternmethod topackages/vitest/src/node/core.tsresolveBrowserProjectsinpackages/vitest/src/node/projects/resolveProjects.tsto check for negated pattern exclusion before filtering instances