Skip to content

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

Open
MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/jasmine-vitest-negated-called-once-with
Open

MeAkib wants to merge 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ Proxy