Skip to content

--project='!name' doesn't exclude browser project instances #10130

@felamaslen

Description

@felamaslen

Describe the bug

--project='!name' negation patterns do not exclude browser-based projects because browser instances get a derived name with a suffix (e.g. project-b (chromium)), which doesn't match the negation regex.

Positive selection works correctly. Negation works for non-browser projects.

Reproduction

https://github.com/felamaslen/vitest-project-exclude-repro

git clone https://github.com/felamaslen/vitest-project-exclude-repro.git
cd vitest-project-exclude-repro
npm install
npx playwright install chromium

Positive selection works:

npx vitest run --project=project-a
# Test Files  1 passed (1)
# Tests       1 passed (1)

Negation does not exclude the browser project:

npx vitest run '--project=!project-b'
# ✓ |project-a| a.test.ts > project-a test
# ✓ |project-b (chromium)| b.test.ts > project-b test
# Test Files  2 passed (2)
# Tests       2 passed (2)

Expected: 1 test file (only project-a).
Actual: 2 test files (both run).

Cause

Browser projects create instances with derived names like project-b (chromium). The negation regex ^(?!project\-b$) anchors to end-of-string, so it doesn't match project-b (chromium), and the instance passes through the filter.

Workaround

Adding a trailing wildcard works:

npx vitest run '--project=!project-b*'
# Test Files  1 passed (1)
# Tests       1 passed (1)

System Info

  • vitest: 4.1.4
  • @vitest/browser-playwright: 4.1.4
  • OS: macOS (arm64)
  • Node: v22

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions