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

expect: Improve report when mock-spy matcher fails, part 3 #8697

Merged
merged 2 commits into from
Jul 16, 2019

Conversation

pedrottimark
Copy link
Contributor

Summary

Throw matcher error if n is not a positive safe integer:

  • toHaveBeenNthCalledWith and nthCalledWith
  • toHaveNthReturnedWith and nthReturnedWith

Because baseline code returns pass: false a negative assertion with invalid n cannot fail :(

Do y’all think to throw error instead of false negative (pardon pun) as:

  • breaking change?
  • fixed error?

For consistency with other matcher errors, display received instead of jest.fn() or mock name

matcherName.slice(1) is temporary until future pull requests which will delete period from names in calls to create matcher functions.

Test plan

  • Updated and renamed 8 snapshots for positive assertions
  • Added 4 snapshots for negative assertions

Example pictures baseline at left and improved at right

Examples of positive assertions:

positive CalledWith

positive ReturnedWith

Examples of negative assertions:

negative CalledWIth

negative ReturnedWith

@SimenB
Copy link
Member

SimenB commented Jul 16, 2019

Do y’all think to throw error instead of false negative (pardon pun) as:

  • breaking change?
  • fixed error?

Definitely a bugfix 🙂

@github-actions
Copy link

This pull request 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 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants