{"id":"f5be972be77352fb","repo":"vitest-dev/vitest","slug":"vitest-received-browser-flag-but-no-project-had","errorCode":null,"errorMessage":"Vitest received --browser flag, but no project had a browser configuration.","messagePattern":"Vitest received --browser flag, but no project had a browser configuration\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/core.ts","lineNumber":417,"sourceCode":"        injectTestProjects: this.injectTestProject,\n        defineCacheKeyGenerator: callback => this._fsCache.defineCacheKeyGenerator(callback),\n        /**\n         * @deprecated Use `defineCacheKeyGenerator` instead.\n         */\n        experimental_defineCacheKeyGenerator: (callback) => {\n          if (!this._warnedExperimentalCacheKeyGenerator) {\n            this._warnedExperimentalCacheKeyGenerator = true\n            this.logger.deprecate('`experimental_defineCacheKeyGenerator` is deprecated. Use `defineCacheKeyGenerator` instead.')\n          }\n          this._fsCache.defineCacheKeyGenerator(callback)\n        },\n      }))\n    }))\n\n    if (resolved.cliOptions.browser?.enabled) {\n      const browserProjects = this.projects.filter(p => p.config.browser.enabled)\n      if (!browserProjects.length) {\n        throw new Error(`Vitest received --browser flag, but no project had a browser configuration.`)\n      }\n    }\n    if (!this.projects.length) {\n      const filter = toArray(resolved.project).join('\", \"')\n      if (filter) {\n        throw new Error(`No projects matched the filter \"${filter}\".`)\n      }\n      else {\n        let error = `Vitest wasn't able to resolve any project.`\n        if (resolved.browser.enabled && !resolved.browser.instances?.length) {\n          error += ` Please, check that you specified the \"browser.instances\" option.`\n        }\n        throw new Error(error)\n      }\n    }\n\n    if (!this.coreWorkspaceProject) {\n      this.coreWorkspaceProject = TestProject._createBasicProject(this)","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/core.ts#L399-L435","documentation":"The `--browser` CLI flag enables browser mode globally, but it does nothing unless at least one project in the workspace has `browser.enabled: true`. The check at core.ts:414-417 scans resolved projects for browser config and throws if none has it, so you discover the misconfiguration immediately rather than seeing zero browser tests run.","triggerScenarios":"Run `vitest --browser` against a workspace where no project sets `test.browser.enabled = true`.","commonSituations":"Passing --browser expecting it to enable browser mode automatically; browser config commented out or in a different project than the one being run; misnamed config key.","solutions":["Enable browser mode in at least one project: `test: { browser: { enabled: true, instances: [{ browser: 'chromium' }] } }`.","If using a workspace, ensure the project with browser config is included (not filtered out by --project).","Drop --browser if you did not intend to run browser tests."],"exampleFix":"// before — no browser config anywhere, run: vitest --browser\nexport default defineConfig({ test: { environment: 'node' } })\n// after\nexport default defineConfig({ test: { browser: { enabled: true, instances: [{ browser: 'chromium' }] } } })","handlingStrategy":"validation","validationCode":"function assertBrowserProjectExists(projects: { config: { browser: { enabled?: boolean } } }[], cliBrowserEnabled: boolean) {\n  if (cliBrowserEnabled && !projects.some(p => p.config.browser.enabled)) {\n    throw new Error('--browser requires at least one project with browser.enabled')\n  }\n}","typeGuard":"function hasBrowserProject(projects: any[]): boolean {\n  return projects.some(p => p.config?.browser?.enabled)\n}","tryCatchPattern":null,"preventionTips":["Enable browser in a project before passing --browser.","Use a workspace project dedicated to browser tests.","Remove --browser for pure node test runs."],"tags":["cli","browser","workspace","config"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}