{"id":"032fea1887ec2ae1","repo":"vitest-dev/vitest","slug":"all-browser-instances-within-a-project-must-use-th","errorCode":null,"errorMessage":"All browser instances within a project must use the same provider, but found: ${[...providerNames].join(', ')}. Use a single provider for the project, or move the instances into separate projects.","messagePattern":"All browser instances within a project must use the same provider, but found: (.+?)\\. Use a single provider for the project, or move the instances into separate projects\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":416,"sourceCode":"    // must use the same provider. Validate that here and hoist the provider to\n    // the project level so the cluster resolves one even when it is only set per\n    // instance (e.g. connect mode). Because the provider is uniform, any\n    // instance's server factory represents the whole project.\n    const providerNames = new Set<string>()\n    // It's possible to provide the same name and sneak in a different factory\n    const providerFactories = new Set()\n    if (browser.provider?.name) {\n      providerNames.add(browser.provider.name)\n      providerFactories.add(browser.provider.serverFactory)\n    }\n    for (const instance of browser.instances) {\n      if (instance.provider?.name) {\n        providerNames.add(instance.provider.name)\n        providerFactories.add(instance.provider.serverFactory)\n      }\n    }\n    if (providerNames.size > 1 || providerFactories.size > 1) {\n      throw new Error(\n        `All browser instances within a project must use the same provider, but found: ${[...providerNames].join(', ')}. `\n        + `Use a single provider for the project, or move the instances into separate projects.`,\n      )\n    }\n    browser.provider ??= browser.instances.find(instance => instance.provider)?.provider\n\n    // use `chromium` by default when the preview provider is specified\n    // for a smoother experience. if chromium is not available, it will\n    // open the default browser anyway\n    if (!browser.instances.length && browser.provider?.name === 'preview') {\n      browser.instances = [{ browser: 'chromium' }]\n    }\n\n    if (browser.name && instances?.length) {\n      // --browser=chromium filters configs to a single one\n      browser.instances = browser.instances.filter(instance => instance.browser === browser.name)\n\n      // if `instances` were defined, but now they are empty,","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/config/resolveConfig.ts#L398-L434","documentation":"A Vitest project shares one browser Vite server, so every browser instance in that project must resolve to the same provider (both by name and by factory reference). The check at resolveConfig.ts:415 collects provider names and factory references from the project-level `browser.provider` and each `browser.instances[].provider`, and throws if more than one distinct provider is found.","triggerScenarios":"Set `browser: { enabled: true, instances: [{ browser: 'chromium', provider: playwright }, { browser: 'webkit', provider: webdriverio }] }` — two different providers in one project.","commonSituations":"Mixing Playwright and WebdriverIO in a single project; defining the provider on some instances but a different one at the project level; split-testing providers.","solutions":["Use a single provider for all instances in the project (set it once at `browser.provider` and omit per-instance providers).","Move instances that need a different provider into a separate Vitest project (separate `defineProject`/workspace entry).","Remove the per-instance `provider` overrides so they inherit the project-level factory."],"exampleFix":"// before\nexport default defineProject({ test: { browser: { enabled: true, instances: [\n  { browser: 'chromium', provider: playwright },\n  { browser: 'webkit', provider: webdriverio },\n] } } })\n// after — split into two projects\nexport default defineWorkspace([\n  { test: { name: 'pw', browser: { enabled: true, provider: playwright, instances: [{ browser: 'chromium' }] } } },\n  { test: { name: 'wdio', browser: { enabled: true, provider: webdriverio, instances: [{ browser: 'webkit' }] } } },\n])","handlingStrategy":"type-guard","validationCode":"function assertSingleBrowserProvider(project: { browser?: { provider?: any; instances?: { provider?: any }[] } }) {\n  const names = new Set<string>()\n  if (project.browser?.provider?.name) names.add(project.browser.provider.name)\n  for (const inst of project.browser?.instances ?? []) {\n    if (inst.provider?.name) names.add(inst.provider.name)\n  }\n  if (names.size > 1) throw new Error(`Multiple browser providers in one project: ${[...names].join(', ')}`)\n}","typeGuard":"function hasUniformProvider(project: any): boolean {\n  const names = new Set<string>()\n  if (project.browser?.provider?.name) names.add(project.browser.provider.name)\n  for (const inst of project.browser?.instances ?? []) if (inst.provider?.name) names.add(inst.provider.name)\n  return names.size <= 1\n}","tryCatchPattern":null,"preventionTips":["Set browser.provider once at the project level and omit per-instance providers.","Split mixed-provider setups into separate workspace projects.","Validate the provider set in a config sanity check."],"tags":["config","browser","provider","workspace","multi-project"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}