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 1 #8640

Merged
merged 2 commits into from
Jul 4, 2019

Conversation

pedrottimark
Copy link
Contributor

Summary

Improve Matcher error reports for all 20 mock-spy matchers

Indentation changed in spyMatchers.ts because of function to access this: MatcherState but the actual changes are limited to:

  • declare expectedArgument and options
  • edit arguments in ensureNoExpected calls
  • edit arguments in ensureExpectedIsNumber calls
  • edit arguments in ensureMock calls
  • rewrite ensureMock function

The matcherName.slice(1) is temporary to omit . in matcher error snapshots only

Future pull requests in this series will remove . from matcher names in create function calls

Breaking Residue for Jest 25

  • Distinguish ensureMock from ensureMockOrSpy because Jasmine spy does not store return values, true?
  • Replace ensureExpectedIsNumber with ensureExpectedIsNonNegativeInteger
  • Write ensureNthIsPositiveInteger function which verifies safe integer and does not call parseInt

Test plan

Updated 76 snapshots

matcher change to test
1 lastCalledWith
1 lastReturnedWith
1 nthCalledWith
1 nthReturnedWith
3 toBeCalled
13 toBeCalledTimes .not works only on spies or jest.fn
1 toBeCalledWith
3 toHaveBeenCalled
13 toHaveBeenCalledTimes .not works only on spies or jest.fn
1 toHaveBeenCalledWith
1 toHaveBeenLastCalledWith
1 toHaveBeenNthCalledWith
1 toHaveLastReturnedWith
1 toHaveNthReturnedWith
3 toHaveReturned .not works only on jest.fn
13 toHaveReturnedTimes
1 toHaveReturnedWith
3 toReturn .not works only on jest.fn
13 toReturnTimes
1 toReturnWith

@codecov-io
Copy link

codecov-io commented Jul 3, 2019

Codecov Report

Merging #8640 into master will increase coverage by 0.09%.
The diff coverage is 88.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8640      +/-   ##
==========================================
+ Coverage    63.4%   63.49%   +0.09%     
==========================================
  Files         274      274              
  Lines       11342    11372      +30     
  Branches     2770     2770              
==========================================
+ Hits         7191     7221      +30     
  Misses       3534     3534              
  Partials      617      617
Impacted Files Coverage Δ
packages/expect/src/spyMatchers.ts 89.02% <88.39%> (+1.58%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b64bb4...e838f78. Read the comment docs.

@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