Skip to content

fix(@schematics/angular): keep the meaning of negated toHaveBeenCalledOnceWith in refactor-jasmine-vitest - #34616

Merged
dgp1130 merged 1 commit into
angular:mainfrom
MeAkib:fix/jasmine-vitest-negated-called-once-with
Nov 3, 2026
Merged

dgp1130 merged 1 commit into
angular:mainfrom
MeAkib:fix/jasmine-vitest-negated-called-once-with

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

expect(spy).not.toHaveBeenCalledOnceWith(...) was split into not.toHaveBeenCalledTimes(1) and not.toHaveBeenCalledWith(...), which asserts that neither condition holds instead of not both. For example, a spy called twice with the same arguments passed before the migration and failed after it.

Transform the negated form to not.toHaveBeenCalledExactlyOnceWith(...), which has the same meaning.

…dOnceWith in refactor-jasmine-vitest

`expect(spy).not.toHaveBeenCalledOnceWith(...)` was split into
`not.toHaveBeenCalledTimes(1)` and `not.toHaveBeenCalledWith(...)`, which asserts
that neither condition holds instead of not both. For example, a spy called twice
with the same arguments passed before the migration and failed after it.

Transform the negated form to `not.toHaveBeenCalledExactlyOnceWith(...)`, which
has the same meaning.

@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 transformCalledOnceWith transformer in the Jasmine-to-Vitest refactoring schematic to correctly handle negated assertions. Specifically, it transforms .not.toHaveBeenCalledOnceWith() into .not.toHaveBeenCalledExactlyOnceWith() instead of splitting it into two separate negated assertions, which would alter the logical meaning. A corresponding unit test has also been added to verify this behavior. I have no feedback to provide.

@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Nov 3, 2026
@dgp1130
dgp1130 merged commit 3436f92 into angular:main Nov 3, 2026
41 of 42 checks passed
@dgp1130

dgp1130 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

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

@MeAkib
MeAkib deleted the fix/jasmine-vitest-negated-called-once-with branch November 4, 2026 06:38
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.

4 participants