You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The assertion of toHaveBeenNthCalledWith compares the arguments but doesn't check if the spy has been called Nth times. Doing this, the assertion error is about the mismatch between arguments instead of the number of invocations.
FAIL index.test.js > should work
AssertionError: expected 3rd "spy" call to have been called with [ 'fail' ]
- Expected:
Array [
"fail",
]
+ Received:
undefined
For reference, the jest output:
n: 3
Expected: "fail"
Received
2: "baz"
Number of calls: 2
Thanks for the issue with reproduction. Yeah, Vitest's error message is not really clear, but I'm not sure Jest's output does so much better either.
The call arguments (array) are checked against undefined, so I don't think this will make assertions to pass when it should fail. Probably, we can just tweak the error message to append something like this:
expected 3rd "spy" call to have been called with [ 'fail' ], but only called 2 times.
Describe the bug
The assertion of
toHaveBeenNthCalledWith
compares the arguments but doesn't check if the spy has been called Nth times. Doing this, the assertion error is about the mismatch between arguments instead of the number of invocations.For reference, the jest output:
Reproduction
Here is a repository to check jest vs vitest outputs: https://github.com/Takeno/vitest-toHaveBeenNthCalledWith
To reproduce the test:
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: