-
Notifications
You must be signed in to change notification settings - Fork 638
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
assertRejects
and assertThrows
should return the caught error
#2220
Comments
Sounds good to me, this should be a simple change. |
Hey! I'd like to take this issue. |
@mrkldshv please do! |
I think we discussed similar suggestion before, but we didn't accept it based on the design principle |
(Note: we added |
Right, I've just looked through previous discussion. As pointed by @kt3k, it wasn't added because |
I think the "Assertions shouldn't have return values." rule is rather arbitrary. I think in this case returning an error is totally reasonable. the error callback does not really solve the issue for me, because I may need to do some async work with the error |
In this previous issue I proposed a similar change to having these functions return the values thrown. I believe the fix for this could also be made to be a fix for that issue. Here is a link to my comment there. It would be good to keep error class and message arguments as a shorthand for both asserting that they throw/reject and asserting that it is an Error that was thrown. |
I'm open to changing that rule now as it's requested/suggested many times and it seems to have some practical use case. @kitsonk What do you think about this suggested change? Do you have any concerns/objections? |
@kt3k Should we close this issue? |
@mrkldshv Yes, thanks! |
It'd be nice if these functions returned the error they caught, so users could do more intricate assertions on the error itself.
The text was updated successfully, but these errors were encountered: