Skip to content

fix(@angular/build): ensure Vitest mock patching is executed only once#32877

Merged
clydin merged 1 commit into
angular:mainfrom
clydin:fix/vitest-mock-patch-guard
Mar 27, 2026
Merged

fix(@angular/build): ensure Vitest mock patching is executed only once#32877
clydin merged 1 commit into
angular:mainfrom
clydin:fix/vitest-mock-patch-guard

Conversation

@clydin

@clydin clydin commented Mar 27, 2026

Copy link
Copy Markdown
Member

Wrap the Vitest mocking overrides in a global guard to prevent repeated execution in shared environments or watch mode runs.

Wrap the Vitest mocking overrides in a global guard to prevent repeated execution in shared environments or watch mode runs.
@clydin clydin added the target: patch This PR is targeted for the next patch release label Mar 27, 2026

@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 mock patching logic in the Angular build system to prevent multiple applications of the patch. It introduces a global symbol check on globalThis to ensure the vi.mock methods are only wrapped once. I have no feedback to provide.

@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Mar 27, 2026
@clydin
clydin merged commit e558117 into angular:main Mar 27, 2026
38 checks passed
@clydin

clydin commented Mar 27, 2026

Copy link
Copy Markdown
Member Author

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

@clydin
clydin deleted the fix/vitest-mock-patch-guard branch March 27, 2026 16:16
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@angular/build:unit-test: "vitest-mock-patch" re-patches for each test file run in same vitest worker context causing vi.mock to fail

2 participants