vitest-dev/vitest · error · Error

The instance cannot have a different provider from its…

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

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.

Solutions

  1. Make the instance provider match the parent, or remove the instance-level provider so it inherits.
  2. If you truly need a different provider, split into a separate project rather than an instance.
  3. Standardize on one provider per project.

Example fix

// before
browser: {
  provider: 'playwright',
  instances: [{ name: 'edge', browser: 'edge', provider: 'webdriverio' }]
}
// after - inherit parent provider
browser: {
  provider: 'playwright',
  instances: [{ name: 'edge', browser: 'edge' }]
}
Defensive patterns

Strategy: validation

Validate before calling

// Enforce provider consistency within a project.
function validateProviderConsistency(parentProvider: string | undefined, instances: { provider?: { name?: string }; name?: string }[]) {
  for (const inst of instances) {
  if (parentProvider && inst.provider?.name && inst.provider.name !== parentProvider) {
  throw new Error(`Instance "${inst.name}" provider "${inst.provider.name}" != parent "${parentProvider}"`)
  }
  }
}

Type guard

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

Prevention

When it happens

Trigger: instance.provider.name and projectConfig.browser.provider.name are both set and are different strings, hitting the explicit mismatch check.

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

Related errors


AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11). Data as JSON: /api/errors/7adaa1883ed0ab03. Report an issue: GitHub.

Appendix: source

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

    // 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 1fa9837ec2)