-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Docs - Expect API - toThrow - Added a note about the type of value thrown #8772
Conversation
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 cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Looks like the jest-circus test failed, it doesn't appear related to the readme, but I could be wrong. Please advise, thanks! |
|
@SSTPIERRE2 Thank you for contributing to Jest. To help interact on your contribution:
For example, test('toThrow without expected value', () => {
const received = () => {
throw 13;
};
expect(received).toThrow();
expect(received).not.toThrow();
}); expect(received).not.toThrow()
Thrown value: 13 This improvement in the report from #7621 in Jest 24.0.0 or later P.S. Yes, ignore When you edit Jest |
Rebasing on master should fix CI, fwiw |
3215722
to
06dccdb
Compare
06dccdb
to
0bd48ca
Compare
Codecov Report
@@ Coverage Diff @@
## master #8772 +/- ##
=======================================
Coverage 64.13% 64.13%
=======================================
Files 292 292
Lines 12452 12452
Branches 3072 3072
=======================================
Hits 7986 7986
Misses 3821 3821
Partials 645 645 Continue to review full report at Codecov.
|
From #8772 (comment), I don't think the docs change is correct, so closing. Feel free to open a new PR if I'm mistaken! |
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. |
Summary
I and some others have ran into issues where one is testing some code they expect to throw, but the code doesn't specifically throw an instance of
Error
, the test will simply fail without explanation. This can be due to throwing anything other thannew Error(...)
, where Jest will not recognize what the function has thrown. This addition to the docs merely clarifies thattoThrow
is specifically looking for an instance ofError
.Test plan
None, simple addition to the docs for clarification.