Skip to content

Multi-project debug fails with confusing message when --project is specified #9166

@npbenjohnson

Description

@npbenjohnson

Describe the bug

Barebones playwright project with a base defineProject config that points at the packages folder. One package with a name and minimal browser config for playwright/chromium.

Tests all run fine at root with
vitest run --inspect --no-file-parallelism
Project load fails at root with
vitest run --inspect --no-file-parallelism --project common it fails

Reproduction

The resulting message is:

  [errors]: [
    Error: --inspect does not work with
    {
      browser: {
        provider: playwright(),
        instances: [
          { browser: 'chromium' }
        ],
      },
    }

    Use either:
    {
      browser: {
        provider: playwright(),
        instances: [
          { browser: 'chromium' }
        ],
      },
    }

    ...or disable --inspect

        at resolveConfig$1 (file:///D:/source/frontend/node_modules/vitest/dist/chunks/coverage.CtyeYmKM.js:2578:10)
        at TestProject._configureServer (file:///D:/source/frontend/node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:10138:18)
        at BasicMinimalPluginContext.configureServer (file:///D:/source/frontend/node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:9603:19)
        at _createServer (file:///D:/source/frontend/node_modules/vite/dist/node/chunks/config.js:25593:97)
        at createViteServer (file:///D:/source/frontend/node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:9810:17)
        at initializeProject (file:///D:/source/frontend/node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:10221:2)
        at async Promise.allSettled (index 0)
        at resolveProjects (file:///D:/source/frontend/node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:10315:35)
        at Vitest._setServer (file:///D:/source/frontend/node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:12144:20)
        at BasicMinimalPluginContext.handler (file:///D:/source/frontend/node_modules/vitest/dist/chunks/cli-api.C7sYjHmQ.js:13071:6)
  ]
}

The failure point is that for some reason when a project is provided, this method is called and there is no way it would ever return true:

// File: vitest\dist\chunks\coverage.CtyeYmKM.js line 2822
function hasBrowserChromium(vitest, config) {
	const browser = config.browser;
	if (!browser || !browser.provider || browser.provider.name === "preview" || !browser.enabled) return false;
	if (browser.name) return isChromiumName(browser.provider.name, browser.name);
	if (!browser.instances) return false;
	return browser.instances.some((instance) => {
		const name = instance.name || (config.name ? `${config.name} (${instance.browser})` : instance.browser);
		// browser config is filtered out <--- FAILURE: "name" here is not the cli provided --project, it is the browser provider name, so this always returns false
		if (!vitest.matchesProjectFilter(name)) return false;
		return isChromiumName(browser.provider.name, instance.browser);
	});
}

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (22) x64 Intel(R) Core(TM) Ultra 7 155H
    Memory: 33.11 GB / 63.46 GB
  Binaries:
    Node: 20.19.5 - C:\nvm4w\nodejs\node.EXE
    npm: 11.6.4 - C:\nvm4w\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (142.0.3595.90)
  npmPackages:
    @vitejs/plugin-vue: 6 => 6.0.2
    @vitest/browser-playwright: 4 => 4.0.15
    @vitest/ui: 4 => 4.0.15
    vite: 7 => 7.2.6
    vitest: ^4.0.15 => 4.0.15

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions