{"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":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/projects/resolveProjects.ts","lineNumber":689,"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":671,"sourceCodeEnd":707,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/projects/resolveProjects.ts#L671-L707","documentation":"An instance may override the provider (resolveProjects.ts:688-690) only if the parent project didn't pin a provider, or with the same provider. If both parent (projectConfig.browser.provider.name) and instance (instance.provider.name) specify providers and they differ, Vitest throws. This enforces that all instances of one project share a single provider implementation.","triggerScenarios":"Parent config sets browser.provider = 'playwright' and an instance sets provider = 'webdriverio' (or vice versa); mixing provider names across instances of the same project.","commonSituations":"Migrating from webdriverio to playwright and leaving a stale instance provider; copy-pasting an instance from a different project that used another provider; intending to test the same browser engine under two providers (not supported per-project).","solutions":["Pick one provider per project and use it consistently for all instances; remove provider from instances to inherit the parent.","If you genuinely need two providers, define two separate projects (one per provider) instead of instances under one project.","Set the provider only at the parent level and let instances inherit."],"exampleFix":"// before\ntest: {\n  browser: {\n    enabled: true,\n    provider: 'playwright',\n    instances: [{ browser: 'chromium', provider: 'webdriverio' }],\n  },\n}\n\n// after\ntest: {\n  browser: {\n    enabled: true,\n    provider: 'playwright',\n    instances: [{ browser: 'chromium' }], // inherits playwright\n  },\n}","handlingStrategy":"validation","validationCode":"const parentProvider = config.browser.provider?.name\nfor (const inst of config.browser.instances ?? []) {\n  const ip = inst.provider?.name\n  if (ip && parentProvider && ip !== parentProvider) {\n    throw new Error(`Instance '${inst.name ?? inst.browser}' provider '${ip}' != parent '${parentProvider}'`)\n  }\n}","typeGuard":"function providersConsistent(parent: string | undefined, instances: { provider?: { name?: string } }[]): boolean {\n  return instances.every(i => !i.provider?.name || !parent || i.provider.name === parent)\n}","tryCatchPattern":null,"preventionTips":["Set provider once at the project level and inherit on instances.","Need two providers? Use two projects, not two instances.","Remove stale provider overrides when migrating."],"tags":["browser","provider","instances","configuration"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}