Skip to content

fix: apply browser CLI options only if the project has the browser set in the config already #7984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 19, 2025

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented May 15, 2025

Description

This PR changes how --browser CLI flags (and API options) affect configuration. If user config doesn't have the browser setup already (an object without enabled: false), then they don't affect the config at all. Vitest will throw an error if no projects define the browser config, but the --browser CLI option was set. The --browser.enabled still works the same way and will override options even if the config has enabled: false.

Hopefully, we can make simplify this when Vite 7 is out.

This PR also fixes a regression from 3.1.3 when extend: true wouldn't correctly extend the browser configuration.

Fixes #7944
Fixes #7964

Note

This PR needs to be backported to 3.1.

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.

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:.

Copy link

netlify bot commented May 15, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 3459559
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/68263c5b2fbfdb0008647d7d
😎 Deploy Preview https://deploy-preview-7984--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.

@sheremet-va sheremet-va changed the base branch from main to v3.1 May 16, 2025 14:46
@sheremet-va sheremet-va changed the base branch from v3.1 to main May 16, 2025 14:46
@sheremet-va sheremet-va added this to the 3.2.0 milestone May 19, 2025
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

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

If user config doesn't have the browser setup already (an object without enabled: false), then they don't affect the config at all. Vitest will throw an error [...]

Is this intentional breaking change? Browser mode is experimental, so yes, it is allowed within non-major semver update.

So for example previously vitest --browser --browser.name=chromium --browser.provider=playwright without any config file worked, now it throws an error.

@AriPerkkio
Copy link
Member

/ecosystem-ci run

@vitest-ecosystem-ci
Copy link

vitest-ecosystem-ci bot commented May 19, 2025

📝 Ran ecosystem CI: Open

suite result
nuxt-test-utils ✅ success
elk ✅ success
nuxt ✅ success
effect ❌ failure
lerna-lite ✅ success
vue ✅ success
sveltejs-cli ✅ success
vitest-sonar-reporter ✅ success
zustand ✅ success
vitest-browser-examples ✅ success
vitest-coverage-large ✅ success
aria-live-capture ✅ success
vite ✅ success
vitest-benchmark-large ✅ success
vitest-in-webcontainer ✅ success
vitest-reporters-large ✅ success
webcontainer-test ❌ failure
vitest-vscode ✅ success

@sheremet-va
Copy link
Member Author

sheremet-va commented May 19, 2025

Is this intentional breaking change? Browser mode is experimental, so yes, it is allowed within non-major semver update.

So for example previously vitest --browser --browser.name=chromium --browser.provider=playwright without any config file worked, now it throws an error.

Yes, this is intentional breaking change.

@sheremet-va sheremet-va merged commit 703581b into vitest-dev:main May 19, 2025
11 of 13 checks passed
@sheremet-va sheremet-va deleted the fix/cli-browser-options branch May 19, 2025 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants