[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix: --project negation excludes browser instances (#10131)

authored by

Fela Maslen and committed by
GitHub
(Apr 14, 2026, 8:53 AM +0200) 9423dc08 b865b4d8

+78 -3
+15
packages/vitest/src/node/core.ts
··· 1643 1643 return regexp.test(name) 1644 1644 }) 1645 1645 } 1646 + 1647 + /** @internal */ 1648 + isExcludedByProjectFilter(name: string): boolean { 1649 + const projects = this._config?.project || this._cliOptions?.project 1650 + if (!projects || !projects.length) { 1651 + return false 1652 + } 1653 + return toArray(projects).some((project) => { 1654 + if (!project.startsWith('!')) { 1655 + return false 1656 + } 1657 + const positivePattern = project.slice(1) 1658 + return wildcardPatternToRegExp(positivePattern).test(name) 1659 + }) 1660 + } 1646 1661 } 1647 1662 1648 1663 function assert(condition: unknown, property: string, name: string = property): asserts condition {
+59
test/cli/test/config/browser-configs.test.ts
··· 317 317 expect(projects[1].config.include).toEqual(['**/*.test.{js,ts}']) 318 318 }) 319 319 320 + test('negation filter excludes all browser instances', async () => { 321 + const { projects } = await vitest({ project: '!myproject' }, { 322 + projects: [ 323 + { 324 + test: { 325 + name: 'myproject', 326 + browser: { 327 + enabled: true, 328 + provider: playwright(), 329 + headless: true, 330 + instances: [ 331 + { browser: 'chromium' }, 332 + { browser: 'firefox' }, 333 + { browser: 'webkit' }, 334 + ], 335 + }, 336 + }, 337 + }, 338 + { 339 + test: { 340 + name: 'other', 341 + }, 342 + }, 343 + ], 344 + }) 345 + expect(projects.map(p => p.name)).toEqual([ 346 + 'other', 347 + ]) 348 + }) 349 + 350 + test('negation wildcard filter excludes all matching browser instances', async () => { 351 + const { projects } = await vitest({ project: '!my*' }, { 352 + projects: [ 353 + { 354 + test: { 355 + name: 'myproject', 356 + browser: { 357 + enabled: true, 358 + provider: playwright(), 359 + headless: true, 360 + instances: [ 361 + { browser: 'chromium' }, 362 + { browser: 'firefox' }, 363 + ], 364 + }, 365 + }, 366 + }, 367 + { 368 + test: { 369 + name: 'other', 370 + }, 371 + }, 372 + ], 373 + }) 374 + expect(projects.map(p => p.name)).toEqual([ 375 + 'other', 376 + ]) 377 + }) 378 + 320 379 test('filter for the global browser project includes all browser instances', async () => { 321 380 const { projects } = await vitest({ project: 'myproject' }, { 322 381 projects: [
+4 -3
packages/vitest/src/node/projects/resolveProjects.ts
··· 211 211 if (!project.config.browser.enabled) { 212 212 return 213 213 } 214 + const originalName = project.config.name 214 215 const instances = project.config.browser.instances || [] 215 - if (instances.length === 0) { 216 + if (instances.length === 0 || vitest.isExcludedByProjectFilter(originalName)) { 216 217 removeProjects.add(project) 217 218 return 218 219 } 219 - const originalName = project.config.name 220 - // if original name is in the --project=name filter, keep all instances 220 + // if original name matches a positive filter, keep all instances 221 + // otherwise, filter instances individually (user may target a specific instance name) 221 222 const filteredInstances = vitest.matchesProjectFilter(originalName) 222 223 ? instances 223 224 : instances.filter((instance) => {