Skip to content

Conversation

@paescuj
Copy link
Contributor

@paescuj paescuj commented Oct 14, 2025

The prefer-called-exactly-once-with rule assumed that if two matchers for the same expect argument were found, they would be a toHaveBeenCalledOnce / toHaveBeenCalledWith pair:

expect(x).toHaveBeenCalledOnce();
expect(x).toHaveBeenCalledWith('hoge');

However, they might as well be two toHaveBeenCalledWith calls:

expect(x).toHaveBeenCalledWith('hoge');
expect(x).toHaveBeenCalledWith('foo');

In the latter case, the rule should not apply.


Under the assumption that this case is referred to in the issue, as other cases have already been covered (such as only one or more than 2 toHaveBeenCalledWith calls): Fixes #781

Copy link
Member

@veritem veritem left a comment

Choose a reason for hiding this comment

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

thanks

@veritem veritem merged commit 4464657 into vitest-dev:main Oct 14, 2025
4 checks passed
@paescuj paescuj deleted the fix/prefer-called-exactly-once-with branch October 14, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prefer-called-exactly-once-with --fix is not transparent

2 participants