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

fix(@jest/types): allow the *ReturnedWith matchers to be called with no argument #13385

Merged
merged 2 commits into from
Oct 4, 2022
Merged

fix(@jest/types): allow the *ReturnedWith matchers to be called with no argument #13385

merged 2 commits into from
Oct 4, 2022

Conversation

mrazauskas
Copy link
Contributor

From https://github.com/facebook/jest/pull/13383/files#r986873627

Summary

Apparently the *ReturnedWith matchers work when called with no arguments:

https://github.com/facebook/jest/blob/ae8a5a293e1339e1e409b8f73f5b6ef4e69988c6/packages/expect/src/__tests__/spyMatchers.test.ts#L873-L877

Current typings of the matchers require an argument. At first expect(someFn).toHaveReturnedWith() looks odd, but I think that makes sense. A function can be called with no args and is not required to have a return statement. This is well reflected with: toHaveBeenCalledWith() and toHaveReturnedWith(). In other words, a function is allowed to return a void.

Or logic of the matcher should be reworked in the next major? Not sure about that.

Test plan

Type tests are adjusted.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

makes sense 👍

@SimenB SimenB merged commit dcd39f0 into jestjs:main Oct 4, 2022
@mrazauskas mrazauskas deleted the fix-jest-types-ReturnedWith-arg branch October 4, 2022 17:54
@github-actions
Copy link

github-actions bot commented Nov 4, 2022

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 Nov 4, 2022
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 this pull request may close these issues.

2 participants