vitest-dev/vitest · error · Error

The instance cannot have a different provider from its paren

Error message

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.

What it means

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.

Source

Thrown at packages/vitest/src/node/projects/resolveProjects.ts:689

    // created (instances link to it via `_parent` for the browser provider).
    // The parent's name is removed from `names` because the instance names
    // take its place in the user-facing project list.
    names.delete(parentName)
    result.push({ ...entry, hidden: true })

    filteredInstances.forEach((instance, index) => {
      const browser = instance.browser
      if (!browser) {
        const nth = index + 1
        const ending = nth === 2 ? 'nd' : nth === 3 ? 'rd' : 'th'
        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.`)
      }
      const name = instance.name
      if (name == null) {
        throw new Error(`The browser configuration must have a "name" property. This is a bug in Vitest. Please, open a new issue with reproduction`)
      }
      if (instance.provider?.name != null && projectConfig.browser.provider?.name != null && instance.provider?.name !== projectConfig.browser.provider?.name) {
        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.`)
      }

      const provider = instance.provider?.name ?? projectConfig.browser.provider?.name ?? 'preview'

      // Browser-mode CDP only features:
      if (provider === 'preview' || !isChromiumName(provider, browser)) {
        const browserConfig = `
{
  browser: {
    provider: ${provider}(),
    instances: [
      ${(filteredInstances || []).map(i => `{ browser: '${i.browser}' }`).join(',\n      ')}
    ],
  },
}
          `.trim()

        const preferredProvider = provider === 'preview'

View on GitHub (pinned to d568f8ce37)

Solutions

  1. Pick one provider per project and use it consistently for all instances; remove provider from instances to inherit the parent.
  2. If you genuinely need two providers, define two separate projects (one per provider) instead of instances under one project.
  3. Set the provider only at the parent level and let instances inherit.

Example fix

// before
test: {
  browser: {
    enabled: true,
    provider: 'playwright',
    instances: [{ browser: 'chromium', provider: 'webdriverio' }],
  },
}

// after
test: {
  browser: {
    enabled: true,
    provider: 'playwright',
    instances: [{ browser: 'chromium' }], // inherits playwright
  },
}
Defensive patterns

Strategy: validation

Validate before calling

const parentProvider = config.browser.provider?.name
for (const inst of config.browser.instances ?? []) {
  const ip = inst.provider?.name
  if (ip && parentProvider && ip !== parentProvider) {
    throw new Error(`Instance '${inst.name ?? inst.browser}' provider '${ip}' != parent '${parentProvider}'`)
  }
}

Type guard

function providersConsistent(parent: string | undefined, instances: { provider?: { name?: string } }[]): boolean {
  return instances.every(i => !i.provider?.name || !parent || i.provider.name === parent)
}

Prevention

When it happens

Trigger: Parent config sets browser.provider = 'playwright' and an instance sets provider = 'webdriverio' (or vice versa); mixing provider names across instances of the same project.

Common situations: 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).

Related errors


AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03). Data as JSON: /data/errors/7adaa1883ed0ab03.json. Report an issue: GitHub.