New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toHaveBeenCalledOnceWith only asserts a match on the first parameter. #517
Comments
I'm seeing the same behavior, and it's really unexpected to me. The |
@loyaj What you are suggesting is implied by the name is the intended behavior. |
I'm going to close this one in favor of #518, just because that one more precisely describes the issue. |
Oh, I’m still thinking this issue is describing a separate problem from #518, is it not? Jest’s |
Ah. You're right. I was looking at was ultimately implemented, but that doesn't match what was described in #138. |
I haven't found a way to make this work with varargs. Jest seems to pass only the first parameter as |
That's a pretty big issue... We were about to introduce |
I'm not sure if this would be classed as a bug or a feature, so apologies for any mistakes raising the issue.
Feature Request
Description: toHaveBeenCalledOnceWith currently only matches against the first parameter provided to a mock function.
Possible solution:
In
toHaveBeenCalledOnceWith.js
, line 40 readsconst pass = passOnce && this.equals(expected, received.mock.calls[0][0]);
I believe that this should probably be changed to
this.equals(expected, received.mock.calls[0]);
and assert equality on the whole array of parameters passed to the mock function in the first call. This may need the function declaration to be changed totoHaveBeenCalledOnceWith(received, ...expected)
or similar to handle multiple arguments.If this is desired, or not so simple to implement, it would be good to make this clear in the documentation.
The text was updated successfully, but these errors were encountered: