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

Add mockFn.mock.lastCall to easily retrieve the last call arguments #10863

Closed
wants to merge 1 commit into from

Conversation

deriegle
Copy link

Summary

When switching from using sinon mocks to jest, one of the nice things that sinon provided was the ability to retrieve the last call arguments easily. I know that you can use mockFn.mock.calls[mockFn.mock.calls.length - 1] to retrieve it, but mock.lastCall seems a lot easier when you're doing it in a bunch of places. I wanted to at least try adding it and see what the response was. I understand if this is not needed, but it seems like a nice little improvement.

Test plan

I've updated types, added tests for the feature and updated documentation. I ran yarn test for the entire test suite to verify that it was working. (Please let me know if there is additional testing that is necessary for this change.)

@facebook-github-bot
Copy link
Contributor

Hi @deriegle!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@deriegle deriegle force-pushed the add-jest-fn-mock-lastCall branch from 1d6f74e to a8935a0 Compare November 24, 2020 16:57
@deriegle deriegle force-pushed the add-jest-fn-mock-lastCall branch from a8935a0 to 2094d5b Compare November 24, 2020 21:53
@SimenB
Copy link
Member

SimenB commented Feb 24, 2022

So sorry, this landed in #12285... Didn't know we already had a PR for it 😬

@SimenB SimenB closed this Feb 24, 2022
@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 Mar 27, 2022
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