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

[no-Jira] Document mock.lastCall #854

Merged
merged 1 commit into from
Jan 16, 2024
Merged

[no-Jira] Document mock.lastCall #854

merged 1 commit into from
Jan 16, 2024

Conversation

canac
Copy link
Contributor

@canac canac commented Jan 12, 2024

Description

I learned from @caleballdrin that mocks have a lastCall property. That feels cleaner than calls[0], so I'm adding it to the testing documentation.

Also fixed a couple of errors in the tests in the docs.

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@canac canac requested review from caleballdrin and dr-bizz January 12, 2024 16:08
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-854.d3dytjb8adxkk5.amplifyapp.com

Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

Thank you for updating this! I wonder if we should keep one Mock with [0][0] to show devs how it normally works.

@canac
Copy link
Contributor Author

canac commented Jan 16, 2024

I wonder if we should keep one Mock with [0][0] to show devs how it normally works.

I was thinking that we could document our best practices for new code and not muddy the water with alternative ways of doing the same thing. There's plenty of code that uses .calls[0] but until/unless we change that them to .lastCall devs can hopefully either figure out what that means or Google it if they don't. Does that sound OK?

@dr-bizz
Copy link
Contributor

dr-bizz commented Jan 16, 2024

I wonder if we should keep one Mock with [0][0] to show devs how it normally works.

I was thinking that we could document our best practices for new code and not muddy the water with alternative ways of doing the same thing. There's plenty of code that uses .calls[0] but until/unless we change that them to .lastCall devs can hopefully either figure out what that means or Google it if they don't. Does that sound OK?

In some tests the last call isn't the call you want to test. I know in most cases it is. I'm fine just using lastCall in the readMe as we want devs to know our best practices.

@canac canac merged commit 4cad43c into main Jan 16, 2024
14 checks passed
@canac canac deleted the document-last-call branch January 16, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants