{"record":{"id":"181783b7344b4f5f","repo":"vitest-dev/vitest","slug":"stackblitz-environment-does-not-support-the-reso","errorCode":null,"errorMessage":"stackblitz environment does not support the ${resolved.browser.provider?.name} provider. Please, use \"@vitest/browser-preview\" instead.","messagePattern":"stackblitz environment does not support the (.+?) provider\\. Please, use \"@vitest/browser-preview\" instead\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":900,"sourceCode":"  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    ))\n    resolved.browser.screenshotFailures = false\n  }\n  else {\n    resolved.browser.screenshotFailures ??= !isPreview && !resolved.browser.ui\n  }\n  if (resolved.browser.provider && resolved.browser.provider.options == null) {\n    resolved.browser.provider.options = {}\n  }\n","sourceCodeStart":882,"sourceCodeEnd":918,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/config/resolveConfig.ts#L882-L918","documentation":"StackBlitz runs in a sandboxed WebContainer that cannot launch a real browser driver. Only the `preview` provider (which opens the user's local browser against the StackBlitz URL) works there. Vitest detects the StackBlitz environment and refuses any other provider, redirecting the user to `@vitest/browser-preview`.","triggerScenarios":"Running Vitest inside StackBlitz with `browser.provider: playwright()` (or webdriverio) and `browser.enabled: true`.","commonSituations":"Reproducing a repo in a StackBlitz link with the same config used locally; a CI matrix that happens to include a StackBlitz runner.","solutions":["Switch to the `preview` provider inside StackBlitz.","Conditionally set the provider based on `process.env.SHELL` / a StackBlitz-detected env var.","Maintain a separate `vitest.stackblitz.config.ts` that uses preview."],"exampleFix":"// before\nimport { playwright } from '@vitest/browser-playwright'\nexport default defineConfig({ test: { browser: { enabled: true, provider: playwright() } } })\n// after (in StackBlitz)\nimport { preview } from '@vitest/browser-preview'\nexport default defineConfig({ test: { browser: { enabled: true, provider: preview() } } })","handlingStrategy":"validation","validationCode":"const isStackBlitz = !!process.env.SHELL?.includes('stackblitz') || !!process.env.WEBcontainer\nif (isStackBlitz && config.test?.browser?.provider?.name !== 'preview') {\n  throw new Error('StackBlitz supports only the preview browser provider.')\n}","typeGuard":"function isStackBlitzEnv(): boolean {\n  return Boolean(process.env.WEB_CONTAINER) || /stackblitz/i.test(process.env.SHELL ?? '')\n}","tryCatchPattern":null,"preventionTips":["Maintain a separate `vitest.stackblitz.config.ts` using the preview provider.","Detect the env early and branch the config before handing off to Vitest."],"tags":["browser","provider","environment","stackblitz"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}