Skip to content

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

Merged
clydin merged 1 commit intoangular: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 intoangular:mainfrom
clydin:fix/vitest-mock-patch-guard

Conversation

@clydin
Copy link
Copy Markdown
Member

@clydin clydin commented Mar 27, 2026

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
Copy link
Copy Markdown

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

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
Copy link
Copy Markdown
Member Author

clydin commented Mar 27, 2026

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