vitest-dev/vitest · error · TypeError
The `browser.provider` configuration was changed to accept…
Error message
The `browser.provider` configuration was changed to accept a factory instead of a string. Add an import of "${resolved.browser.provider}" from "${source}" instead. See: https://vitest.dev/config/browser/provider What it means
In a recent major version the `browser.provider` field changed from a string identifier (`'playwright'`, `'webdriverio'`) to a factory function imported from a dedicated package. Vitest detects the legacy string form and points the user at the correct import. This is a TypeError because the field's runtime type is wrong, not merely a deprecation.
Solutions
- Import the provider factory from `@vitest/browser-playwright` (or `-webdriverio`, `-preview`) and pass the call result to `browser.provider`.
- Install the matching `@vitest/browser-*` package if it is missing.
- Repeat the migration for every workspace project that configures browsers.
Example fix
// before
import { defineConfig } from 'vitest/config'
export default defineConfig({ test: { browser: { provider: 'playwright' } } })
// after
import { defineConfig } from 'vitest/config'
import { playwright } from '@vitest/browser-playwright'
export default defineConfig({ test: { browser: { provider: playwright() } } }) Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof (config.test?.browser as any)?.provider === 'string') {
throw new TypeError('browser.provider must be a factory; migrate from the string form.')
} Type guard
function isLegacyStringProvider(provider: unknown): provider is string {
return typeof provider === 'string'
} Prevention
- Add a post-upgrade codemod that searches for `provider: 'playwright'` and rewrites it.
- Keep a single `browserProviders.ts` module that imports and re-exports each factory.
When it happens
Trigger: Carrying over `browser: { provider: 'playwright' }` from a pre-migration config; docs/tutorial still using the string form.
Common situations: Upgrading Vitest across the major version that introduced factory providers; a monorepo where only one app's config was migrated.
Related errors
- All browser instances within a project must use the same…
- browser is not initialized
- Browser Mode requires the "provider" to always be specified.
- Browser Mode was enabled, but provider was not specified…
- Looks like you set "test.environment" to "browser". To…
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/199e8eeeb863efa4.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vitest/src/node/config/resolveConfig.ts:891
)
}
if (resolved.inspector.enabled) {
resolved.browser.trackUnhandledErrors ??= false
}
resolved.browser.viewport ??= {} as any
resolved.browser.viewport.width ??= 414
resolved.browser.viewport.height ??= 896
resolved.browser.locators ??= {} as any
resolved.browser.locators.testIdAttribute ??= 'data-testid'
resolved.browser.locators.exact ??= true
resolved.browser.locators.errorFormat ??= 'all'
if (typeof resolved.browser.provider === 'string') {
const source = `@vitest/browser-${resolved.browser.provider}`
throw new TypeError(
'The `browser.provider` configuration was changed to accept a factory instead of a string. '
+ `Add an import of "${resolved.browser.provider}" from "${source}" instead. See: https://vitest.dev/config/browser/provider`,
)
}
const isPreview = resolved.browser.provider?.name === 'preview'
if (!isPreview && resolved.browser.enabled && stdProvider === 'stackblitz') {
throw new Error(`stackblitz environment does not support the ${resolved.browser.provider?.name} provider. Please, use "@vitest/browser-preview" instead.`)
}
if (isPreview && resolved.browser.screenshotFailures === true) {
console.warn(c.yellow(
[
`Browser provider "preview" doesn't support screenshots, `,
`so "browser.screenshotFailures" option is forcefully disabled. `,
`Set "browser.screenshotFailures" to false or remove it from the config to suppress this warning.`,
].join(''),
))View on GitHub (pinned to 1fa9837ec2)