{"record":{"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":320,"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":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/config/resolveConfig.ts#L302-L338","documentation":"Vitest removed the `environment: 'browser'` shortcut. Browser Mode is now enabled through the dedicated `test.browser.enabled` flag (and `test.browser.instances`). Setting `test.environment` to the literal string `'browser'` is detected and rejected to prevent a silently misconfigured browser run, because the `browser` environment alone does not spin up the browser provider.","triggerScenarios":"Setting `environment: 'browser'` in a vitest config, or passing `--environment browser` on the CLI, or inheriting an older config that relied on the environment alias.","commonSituations":"Upgrading from an older Vitest where `environment: 'browser'` was the documented entry point; copy-pasting a stale blog post or example.","solutions":["Remove `environment: 'browser'` and set `test.browser.enabled: true` instead.","Define at least one entry in `test.browser.instances` (e.g. `[{ browser: 'chromium' }]`).","Install the appropriate `@vitest/browser-*` provider package if you have not already."],"exampleFix":"// before\ntest: { environment: 'browser' }\n// after\ntest: { browser: { enabled: true, instances: [{ browser: 'chromium' }] } }","handlingStrategy":"validation","validationCode":"if (config.test?.environment === 'browser') {\n  throw new Error('Use test.browser.enabled instead of test.environment: \"browser\".')\n}\n// correct shape\nconfig.test = { ...config.test, browser: { enabled: true, instances: [{ browser: 'chromium' }] } }","typeGuard":"function hasBrowserEnvShortcut(cfg: any): boolean {\n  return cfg?.test?.environment === 'browser'\n}","tryCatchPattern":null,"preventionTips":["After a Vitest major upgrade, run `vitest --showConfig` and grep for `environment: 'browser'`.","Keep browser config behind a `withBrowser()` helper that always sets `browser.enabled` + instances."],"tags":["config","browser","migration"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}