Skip to content
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

toBeCalledWith and lastCalledWith should print some of the call values. #954

Closed
cpojer opened this issue Apr 28, 2016 · 5 comments
Closed

Comments

@cpojer
Copy link
Member

cpojer commented Apr 28, 2016

This has been confusing to me when using these matchers.

  • If a mock function has been called once, instead of "was never called with" we should print the values.
  • If a mock function has been called multiple times we should print the value it was last called with and print "And called N-1 more times."

Example Repro:

const fn = jest.fn();
fn('abc');
expect(fn).toBeCalledWith('abcd');
@petetnt
Copy link
Contributor

petetnt commented Apr 28, 2016

👍 I had #918 up for a while but had an oversight of only showing the latest one. It would be nice to have a way to show all of the calls (for say debugging purposes) with something like --verbose too IMHO.

@cpojer
Copy link
Member Author

cpojer commented May 10, 2016

@petetnt would you mind taking this back on and sending another PR? I think as a start showing the last N calls (3 is a good number!) + the number of overall calls would be very helpful.

@petetnt
Copy link
Contributor

petetnt commented May 10, 2016

@cpojer Sure thing, I'll put in another PR soon(ish) 👍

@petetnt
Copy link
Contributor

petetnt commented May 10, 2016

Filed the PR as #987 🎆

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants