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 negative CalledWith assertion fails #8755

Merged
merged 5 commits into from
Jul 30, 2019

Conversation

pedrottimark
Copy link
Contributor

Summary

For .not.toHaveBeen*CalledWith assertions:

  • repeat not following Expected label
  • replaced called with no arguments with called with 0 arguments to avoid double negative
  • for special case of one call, display Received: whatever on one line
  • but omit the line if received has same serialization as expected

Reason to separate pull requests:

Test plan

Updated 40 snapshots

long name short name
2 toHaveBeenCalled toBeCalled
12 toHaveBeenCalledWith toBeCalledWith
12 toHaveBeenLastCalledWith lastCalledWith
14 toHaveBeenNthCalledWith nthCalledWith

See also pictures in following comment

Example pictures baseline at left and improved at right

@pedrottimark
Copy link
Contributor Author

negative toHaveBeenCalledWith assertions:

CalledWith true 1

CalledWith true 4

negative toHaveBeenLastCalledWith assertions:

LastCalled true 1

LastCalled true 3

negative toHaveBeenNthCalledWith assertions:

NthCalled true 1

NthCalled true 2

NthCalled true 10

Copy link
Contributor

@jeysal jeysal left a comment

Choose a reason for hiding this comment

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

Very nice!

packages/expect/src/spyMatchers.ts Outdated Show resolved Hide resolved
@pedrottimark
Copy link
Contributor Author

What do you think about dim color for equal arguments in report for negative assertions?

In first example, current pull request above possible improvement:

_LastCalled true 3 dim

P.S. Forgot to say before, scenario above is testing an imaginary reverse-order array method

In second and third examples, current pull request at left and possible improvement at right:

_NthCalled true 2 dim

_NthCalled true 10 dim

The reports for positive assertions will need dim color, so we might avoid extra code

@SimenB
Copy link
Member

SimenB commented Jul 30, 2019

Oh yeah, dimming the parts that match makes a lot of sense to me

@jeysal
Copy link
Contributor

jeysal commented Jul 30, 2019

Yes, looks very good 👌

@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.

4 participants