{"record":{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":444,"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":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/config/resolveConfig.ts#L426-L462","documentation":"Each Vitest project spawns one shared browser Vite server, so all `browser.instances` (plus the project-level `browser.provider`) must resolve to the same provider name AND the same server factory. This guard catches both the obvious case (e.g. `playwright` alongside `webdriverio`) and the subtle case where the name matches but the factory reference differs (e.g. two different imported factory objects).","triggerScenarios":"Mixing `browser.provider: playwright()` with an instance carrying `provider: webdriverio()`; importing the provider factory in two different files and assigning different references; instances sourced from different packages despite the same nominal name.","commonSituations":"Multi-browser smoke tests where someone added a second provider per-instance instead of splitting projects; refactor that moved the provider import.","solutions":["Pick one provider for the whole project and reuse that exact factory reference on every instance.","If you genuinely need two providers, split the instances into separate Vitest projects.","Centralise the provider import in a single module and re-export it everywhere it is referenced."],"exampleFix":"// before\nbrowser: {\n  provider: playwright(),\n  instances: [\n    { browser: 'chromium' },\n    { browser: 'firefox', provider: webdriverio() },\n  ],\n}\n// after (split projects)\nprojects: [\n  { test: { browser: { provider: playwright(), instances: [{ browser: 'chromium' }] } } },\n  { test: { browser: { provider: webdriverio(), instances: [{ browser: 'firefox' }] } } },\n]","handlingStrategy":"type-guard","validationCode":"import { playwright } from '@vitest/browser-playwright'\nconst provider = playwright()\nconst instances = [{ browser: 'chromium' as const }, { browser: 'firefox' as const }]\n// ensure every instance uses the SAME provider reference\nconst validated = instances.map(i => ({ ...i, provider }))\nexport default defineConfig({ test: { browser: { provider, instances: validated } } })","typeGuard":"function hasUniformProvider(instances: any[], projectProvider: any): boolean {\n  const factory = projectProvider?.serverFactory\n  return instances.every(i => i?.provider?.serverFactory === factory || i.provider == null)\n}","tryCatchPattern":null,"preventionTips":["Define the provider once at the top of the config and reuse the same reference.","If two providers are genuinely needed, split them into separate `projects` entries."],"tags":["config","browser","provider","validation"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}