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

Simplify async .rejects examples #8965

Closed
wants to merge 1 commit into from
Closed

Simplify async .rejects examples #8965

wants to merge 1 commit into from

Conversation

bschlenk
Copy link
Contributor

The docs state that "If the promise is fulfilled, the test will automatically fail", so it is not necessary to include the expect.assertions(1) calls since the tests will fail automatically if the promise doesn't reject.

Summary

Test plan

The docs state that "If the promise is fulfilled, the test will automatically fail", so it is not necessary to include the `expect.assertions(1)` calls since the tests will fail automatically if the promise doesn't reject.
@facebook-github-bot
Copy link
Contributor

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 up 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 the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@codecov-io
Copy link

Codecov Report

Merging #8965 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #8965   +/-   ##
======================================
  Coverage    64.2%   64.2%           
======================================
  Files         276     276           
  Lines       11718   11718           
  Branches     2868    2868           
======================================
  Hits         7523    7523           
  Misses       3563    3563           
  Partials      632     632

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 1693028...19782da. Read the comment docs.

@jeysal
Copy link
Contributor

jeysal commented Sep 18, 2019

Thanks for bringing this up. In my opinion, it is still a good idea and should be recommended to use expect.assertions as a safeguard once async things are involved, because it is easy to forget to return/await the expect.resolves.

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

@bschlenk
Copy link
Contributor Author

That’s true, it would protect against forgetting to return the promise. However, for this example in particular, it made me question whether rejects actually fails when the Promise resolves okay.

Maybe it would be better to update the text to say that expect.assertions is recommended for that reason, but not required for the test to work?

@jeysal
Copy link
Contributor

jeysal commented Sep 19, 2019

Yeah, mentioning that it is recommended to prevent the common mistake of forgetting to await / return the expect.resolves sounds good to me!

@SimenB
Copy link
Member

SimenB commented Oct 26, 2019

Please update the versioned docs as well when incorporating @jeysal's feedback 🙂

image

@bschlenk
Copy link
Contributor Author

Looks like #9149 was merged in which addresses this PR!

@bschlenk bschlenk closed this Apr 24, 2020
@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.

5 participants