Skip to content

fix: do not throw when browser mode is used without explicit projects (#9801)#9938

Open
oilater wants to merge 4 commits intovitest-dev:mainfrom
hamsurang:fix/9801-allow-browser-without-projects
Open

fix: do not throw when browser mode is used without explicit projects (#9801)#9938
oilater wants to merge 4 commits intovitest-dev:mainfrom
hamsurang:fix/9801-allow-browser-without-projects

Conversation

@oilater
Copy link
Contributor

@oilater oilater commented Mar 21, 2026

Description

Resolves #9801

This PR fixes an issue where Vitest throws an incorrect validation error when browser mode is enabled without an explicit config.projects, even if valid browser.instances are provided.

Implementation

Updated the browser validation logic to distinguish between workspace and non-workspace configurations.

  • When config.projects is not defined, browser mode is allowed as long as valid browser.instances are provided.
  • When using a workspace, validation still ensures that at least one project has browser mode enabled.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Mar 21, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 90cd1e9
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69bee2bcbd29070008dc965c
😎 Deploy Preview https://deploy-preview-9938--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@oilater oilater closed this Mar 21, 2026
@oilater oilater reopened this Mar 21, 2026
if (this._cliOptions.browser?.enabled) {
const browserProjects = this.projects.filter(p => p.config.browser.enabled)
if (!browserProjects.length) {
if (!browserProjects.length && !this.config.browser?.instances?.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed because instances inject new projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants