{"record":{"id":"7adaa1883ed0ab03","repo":"vitest-dev/vitest","slug":"the-instance-cannot-have-a-different-provider-from","errorCode":null,"errorMessage":"The instance cannot have a different provider from its parent. The \"${name}\" instance specifies \"${instance.provider?.name}\" provider, but its parent has a \"${projectConfig.browser.provider?.name}\" provider.","messagePattern":"The instance cannot have a different provider from its parent\\. The \"(.+?)\" instance specifies \"(.+?)\" provider, but its parent has a \"(.+?)\" provider\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/projects/resolveProjects.ts","lineNumber":885,"sourceCode":"    // created (instances link to it via `_parent` for the browser provider).\n    // The parent's name is removed from `names` because the instance names\n    // take its place in the user-facing project list.\n    names.delete(parentName)\n    result.push({ ...entry, hidden: true })\n\n    filteredInstances.forEach((instance, index) => {\n      const browser = instance.browser\n      if (!browser) {\n        const nth = index + 1\n        const ending = nth === 2 ? 'nd' : nth === 3 ? 'rd' : 'th'\n        throw new Error(`The browser configuration must have a \"browser\" property. The ${nth}${ending} item in \"browser.instances\" doesn't have it. Make sure your${projectConfig.name ? ` \"${projectConfig.name}\"` : ''} configuration is correct.`)\n      }\n      const name = instance.name\n      if (name == null) {\n        throw new Error(`The browser configuration must have a \"name\" property. This is a bug in Vitest. Please, open a new issue with reproduction`)\n      }\n      if (instance.provider?.name != null && projectConfig.browser.provider?.name != null && instance.provider?.name !== projectConfig.browser.provider?.name) {\n        throw new Error(`The instance cannot have a different provider from its parent. The \"${name}\" instance specifies \"${instance.provider?.name}\" provider, but its parent has a \"${projectConfig.browser.provider?.name}\" provider.`)\n      }\n\n      const provider = instance.provider?.name ?? projectConfig.browser.provider?.name ?? 'preview'\n\n      // Browser-mode CDP only features:\n      if (provider === 'preview' || !isChromiumName(provider, browser)) {\n        const browserConfig = `\n{\n  browser: {\n    provider: ${provider}(),\n    instances: [\n      ${(filteredInstances || []).map(i => `{ browser: '${i.browser}' }`).join(',\\n      ')}\n    ],\n  },\n}\n          `.trim()\n\n        const preferredProvider = provider === 'preview'","sourceCodeStart":867,"sourceCodeEnd":903,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/projects/resolveProjects.ts#L867-L903","documentation":"Browser instances may override the provider, but only if it agrees with the parent project's provider. If both the instance and the parent specify a provider and they differ, Vitest refuses because mixing providers within one project is unsupported. The error names the instance and both provider values.","triggerScenarios":"instance.provider.name and projectConfig.browser.provider.name are both set and are different strings, hitting the explicit mismatch check.","commonSituations":"Setting the project provider to 'playwright' but an instance to 'webdriverio' (or vice versa), or copy-pasting an instance from a project with a different provider.","solutions":["Make the instance provider match the parent, or remove the instance-level provider so it inherits.","If you truly need a different provider, split into a separate project rather than an instance.","Standardize on one provider per project."],"exampleFix":"// before\nbrowser: {\n  provider: 'playwright',\n  instances: [{ name: 'edge', browser: 'edge', provider: 'webdriverio' }]\n}\n// after - inherit parent provider\nbrowser: {\n  provider: 'playwright',\n  instances: [{ name: 'edge', browser: 'edge' }]\n}","handlingStrategy":"validation","validationCode":"// Enforce provider consistency within a project.\nfunction validateProviderConsistency(parentProvider: string | undefined, instances: { provider?: { name?: string }; name?: string }[]) {\n  for (const inst of instances) {\n  if (parentProvider && inst.provider?.name && inst.provider.name !== parentProvider) {\n  throw new Error(`Instance \"${inst.name}\" provider \"${inst.provider.name}\" != parent \"${parentProvider}\"`)\n  }\n  }\n}","typeGuard":"const providersConsistent = (parent: string | undefined, instances: { provider?: { name?: string } }[]): boolean =>\n  instances.every(i => !parent || !i.provider?.name || i.provider.name === parent)","tryCatchPattern":null,"preventionTips":["Set the provider once at the project level and let instances inherit.","If a different provider is needed, create a separate project.","Audit instances for stray provider overrides."],"tags":["browser","config","instances","provider","validation"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}