vitest-dev / vitest-dev/vitest

`startVitest` + browser mode crashing with `Vitest received --browser flag, but no project had a browser configuration.`

Open
#9,801 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat: browser p3-minor-bug
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

Running browser mode via Node API without projects crashes. Adding projects fixes it.

import { startVitest } from "vitest/node";
import { playwright } from "@vitest/browser-playwright";

const vitest = await startVitest("test", [], {
  browser: {
    enabled: true,
    headless: true,
    provider: playwright(),
    instances: [{ browser: "chromium" }],
  },
});

await vitest.close();
$ node index.mjs 
file:///x/repros/vitest-browser-name/node_modules/.pnpm/vitest@4.0.18_@vitest+browser-playwright@4.0.18/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:12238
                        if (!this.projects.filter((p) => p.config.browser.enabled).length) throw new Error(`Vitest received --browser flag, but no project had a browser configuration.`);
                                                                                                 ^

Error: Vitest received --browser flag, but no project had a browser configuration.
    at Vitest._setServer (file:///x/repros/vitest-browser-name/node_modules/.pnpm/vitest@4.0.18_@vitest+browser-playwright@4.0.18/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:12238:77)
    at BasicMinimalPluginContext.handler (file:///x/repros/vitest-browser-name/node_modules/.pnpm/vitest@4.0.18_@vitest+browser-playwright@4.0.18/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:13158:6)
    at _createServer (file:///x/repros/vitest-browser-name/node_modules/.pnpm/vite@7.3.1/node_modules/vite/dist/node/chunks/config.js:25603:86)
    at createViteServer (file:///x/repros/vitest-browser-name/node_modules/.pnpm/vitest@4.0.18_@vitest+browser-playwright@4.0.18/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:9870:17)
    at createVitest (file:///x/repros/vitest-browser-name/node_modules/.pnpm/vitest@4.0.18_@vitest+browser-playwright@4.0.18/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:13186:17)
    at prepareVitest (file:///x/repros/vitest-browser-name/node_modules/.pnpm/vitest@4.0.18_@vitest+browser-playwright@4.0.18/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:13548:14)
    at startVitest (file:///x/repros/vitest-browser-name/node_modules/.pnpm/vitest@4.0.18_@vitest+browser-playwright@4.0.18/node_modules/vitest/dist/chunks/cli-api.B7PN_QUv.js:13494:14)
    at file:///x/repros/vitest-browser-name/index.mjs:4:16

Node.js v22.22.0
Reproduction

https://stackblitz.com/~/edit/vitest-dev-vitest-pohf9wmu?file=index.mjs&initialPath=/__vitest__/

System Info
Stackblitz
Used Package Manager

pnpm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the index.mjs reproduction with startVitest and the browser configuration shown, then trace the failure through startVitest and Vitest._setServer in the generated cli-api stack. Done means the same no-projects invocation starts browser mode and reaches vitest.close() without the missing browser configuration error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, playwright, typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.