Skip to content

fix(@schematics/angular): add browsers option during vitest browser provider ng-add - #32885

Merged
dgp1130 merged 1 commit into
angular:mainfrom
maruthang:fix-32401-vitest-browser-ng-add
Sep 25, 2026
Merged

dgp1130 merged 1 commit into
angular:mainfrom
maruthang:fix-32401-vitest-browser-ng-add

Conversation

@maruthang

@maruthang maruthang commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix

What is the current behavior?

When running ng add for a Vitest browser provider (e.g., @vitest/browser-playwright), the schematic adds dependencies and updates tsconfig.spec.json but does not configure the browsers option in angular.json. Users must manually add it for tests to run in a browser instead of Node.js/jsdom.

Issue Number: #32401

What is the new behavior?

The schematic now automatically configures the browsers option in the test target of angular.json using updateWorkspace():

  • chromium for Playwright and Preview providers
  • chrome for WebDriverIO

Existing browsers configurations are preserved and not overwritten. Tests cover all three provider types and the preservation of existing config.

Does this PR introduce a breaking change?

  • Yes
  • No

Closes #32401

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Vitest browser schematic to automatically configure the 'browsers' option in 'angular.json' based on the selected provider, defaulting to 'chrome' for WebdriverIO and 'chromium' for Playwright or Preview. It also includes unit tests to verify these configurations and ensure that existing settings are not overwritten. Feedback suggests refactoring the new tests into a parameterized format to reduce duplication and adding a specific test case for the preview provider to ensure full coverage.

Comment thread packages/schematics/angular/vitest-browser/index_spec.ts Outdated
@alan-agius4
alan-agius4 force-pushed the fix-32401-vitest-browser-ng-add branch 3 times, most recently from 08455a6 to 31e17e6 Compare September 25, 2026 09:49
…vitest browser provider ng-add

When adding a Vitest browser provider via ng-add, the schematic now
automatically configures the 'browsers' option in angular.json with an
appropriate default browser (chromium for Playwright/Preview, chrome for
WebDriverIO) instead of only logging a manual instruction.

Fixes angular#32401
@alan-agius4
alan-agius4 force-pushed the fix-32401-vitest-browser-ng-add branch from 31e17e6 to c3d0051 Compare September 25, 2026 09:51
@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Sep 25, 2026

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this.

@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Sep 25, 2026
@dgp1130
dgp1130 merged commit 0530944 into angular:main Sep 25, 2026
68 of 69 checks passed
@dgp1130

dgp1130 commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

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

Labels

action: merge The PR is ready for merge by the caretaker area: @schematics/angular target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng-add support for Vitest browser providers doesn't work

3 participants