{"id":"6256ff1826a1823a","repo":"vitest-dev/vitest","slug":"looks-like-you-set-test-environment-to-browser","errorCode":null,"errorMessage":"Looks like you set \"test.environment\" to \"browser\". To enable Browser Mode, use \"test.browser.enabled\" instead.","messagePattern":"Looks like you set \"test\\.environment\" to \"browser\"\\. To enable Browser Mode, use \"test\\.browser\\.enabled\" instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":292,"sourceCode":"      throw new Error(`Tag name \"${tag.name}\" is invalid. Tag names cannot be a logical operator like \"and\", \"or\", \"not\".`)\n    }\n    if (typeof tag.retry === 'object' && typeof tag.retry.condition === 'function') {\n      throw new TypeError(`Tag \"${tag.name}\": retry.condition function cannot be used inside a config file. Use a RegExp pattern instead, or define the function in your test file.`)\n    }\n    if (tag.priority != null && (typeof tag.priority !== 'number' || tag.priority < 0)) {\n      throw new TypeError(`Tag \"${tag.name}\": priority must be a non-negative number.`)\n    }\n    definedTags.add(tag.name)\n  })\n\n  resolved.name = typeof options.name === 'string'\n    ? options.name\n    : (options.name?.label || '')\n\n  resolved.color = typeof options.name !== 'string' ? options.name?.color : undefined\n\n  if (resolved.environment === 'browser') {\n    throw new Error(`Looks like you set \"test.environment\" to \"browser\". To enable Browser Mode, use \"test.browser.enabled\" instead.`)\n  }\n\n  resolved.benchmark = {\n    ...benchmarkConfigDefaults,\n    ...resolved.benchmark,\n  }\n  if (resolved.benchmark.provider) {\n    resolved.benchmark.provider = resolvePath(\n      resolved.benchmark.provider,\n      resolved.root,\n    )\n  }\n\n  const inspector = resolved.inspect || resolved.inspectBrk\n\n  resolved.inspector = {\n    ...resolved.inspector,\n    ...parseInspector(inspector),","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/config/resolveConfig.ts#L274-L310","documentation":"Vitest removed the `environment: 'browser'` shorthand when Browser Mode became a first-class feature backed by its own server. The check at resolveConfig.ts:291 stops users from using the old string form and points them at `test.browser.enabled`, which is the only way to spin up the browser orchestrator, instances, and provider.","triggerScenarios":"In config set `test: { environment: 'browser' }`, or pass `--environment browser` resolving to this config value. The equality check against the string 'browser' throws.","commonSituations":"Following an outdated tutorial or docs from a pre-Browser-Mode version; migrating from Jest's jsdom/browser env naming; muscle memory from the old happy-dom/node/browser environment list.","solutions":["Enable Browser Mode in config: `test: { browser: { enabled: true } }` and remove `environment: 'browser'`.","If you only need a DOM, keep `environment: 'happy-dom'` or `environment: 'jsdom'` instead.","If migrating, also add at least one `browser.instances` entry or rely on the default chromium instance."],"exampleFix":"// before\nexport default defineConfig({ test: { environment: 'browser' } })\n// after\nexport default defineConfig({ test: { browser: { enabled: true, instances: [{ browser: 'chromium' }] } } })","handlingStrategy":"type-guard","validationCode":"function assertNoBrowserEnv(config: any) {\n  if (config?.test?.environment === 'browser') {\n    throw new Error('Use test.browser.enabled instead of test.environment: \"browser\".')\n  }\n}","typeGuard":"function usesBrowserMode(config: any): boolean {\n  return config?.test?.environment !== 'browser' && !!config?.test?.browser?.enabled\n}","tryCatchPattern":null,"preventionTips":["Search the config for `environment: 'browser'` after upgrading Vitest.","Bookmark the Browser Mode docs and migrate env strings to browser.enabled.","For DOM-only tests prefer 'happy-dom' or 'jsdom'."],"tags":["config","browser","environment","migration"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}