{"record":{"id":"199e8eeeb863efa4","repo":"vitest-dev/vitest","slug":"the-browser-provider-configuration-was-changed-t","errorCode":null,"errorMessage":"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","messagePattern":"The `browser\\.provider` configuration was changed to accept a factory instead of a string\\. Add an import of \"(.+?)\" from \"(.+?)\" instead\\. See: https://vitest\\.dev/config/browser/provider","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":891,"sourceCode":"    )\n  }\n\n  if (resolved.inspector.enabled) {\n    resolved.browser.trackUnhandledErrors ??= false\n  }\n\n  resolved.browser.viewport ??= {} as any\n  resolved.browser.viewport.width ??= 414\n  resolved.browser.viewport.height ??= 896\n\n  resolved.browser.locators ??= {} as any\n  resolved.browser.locators.testIdAttribute ??= 'data-testid'\n  resolved.browser.locators.exact ??= true\n  resolved.browser.locators.errorFormat ??= 'all'\n\n  if (typeof resolved.browser.provider === 'string') {\n    const source = `@vitest/browser-${resolved.browser.provider}`\n    throw new TypeError(\n      'The `browser.provider` configuration was changed to accept a factory instead of a string. '\n      + `Add an import of \"${resolved.browser.provider}\" from \"${source}\" instead. See: https://vitest.dev/config/browser/provider`,\n    )\n  }\n\n  const isPreview = resolved.browser.provider?.name === 'preview'\n\n  if (!isPreview && resolved.browser.enabled && stdProvider === 'stackblitz') {\n    throw new Error(`stackblitz environment does not support the ${resolved.browser.provider?.name} provider. Please, use \"@vitest/browser-preview\" instead.`)\n  }\n  if (isPreview && resolved.browser.screenshotFailures === true) {\n    console.warn(c.yellow(\n      [\n        `Browser provider \"preview\" doesn't support screenshots, `,\n        `so \"browser.screenshotFailures\" option is forcefully disabled. `,\n        `Set \"browser.screenshotFailures\" to false or remove it from the config to suppress this warning.`,\n      ].join(''),\n    ))","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/config/resolveConfig.ts#L873-L909","documentation":"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.","triggerScenarios":"Carrying over `browser: { provider: 'playwright' }` from a pre-migration config; docs/tutorial still using the string form.","commonSituations":"Upgrading Vitest across the major version that introduced factory providers; a monorepo where only one app's config was migrated.","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."],"exampleFix":"// before\nimport { defineConfig } from 'vitest/config'\nexport default defineConfig({ test: { browser: { provider: 'playwright' } } })\n// after\nimport { defineConfig } from 'vitest/config'\nimport { playwright } from '@vitest/browser-playwright'\nexport default defineConfig({ test: { browser: { provider: playwright() } } })","handlingStrategy":"type-guard","validationCode":"if (typeof (config.test?.browser as any)?.provider === 'string') {\n  throw new TypeError('browser.provider must be a factory; migrate from the string form.')\n}","typeGuard":"function isLegacyStringProvider(provider: unknown): provider is string {\n  return typeof provider === 'string'\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["config","browser","provider","migration"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}