-
-
Notifications
You must be signed in to change notification settings - Fork 224
Add matchers for asserting that a promise has resolved or rejected (regardless of value) #130
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This has been sat here for a while, tbh I'm not sure how to go about this, nor how I feel about it either. I was thinking can we tie into the timeout for a test in the jest config and expect it to be completed by the time that timeout comes, (i think 5 seconds default?) |
@mattphillips ping 🙂 |
Hey guys sorry for the delay in coming back to this, I’m currently holidaying and AFK for the most-part. @benjaminkay93 I think this should be possible with the new async matchers. I’d imagine it would be a similar implementation to Jest’s .resolves API. |
okay, im happy to give this a go if nobody else wants to, are there any examples of async custom matchers knockin about? would make life easier, ill ofc have a google too |
@benjaminkay93 check out the expect extend docs there is an async section https://jestjs.io/docs/en/expect#expectextendmatchers Let me know how you get on with this, if you need a hand I’ll be back from my travels in about a week so can look into this too then 😄 |
sweet cheers matt, enjoy your hols! 🏖 |
Would it be possible to return the error message when Note: |
Hi there, congratulations for this awesome library! I was just browsing through this issue, and I have the impression it has since been implemented? Check .toResolve()/.toReject() |
Feature Request
Description:
I would like a way to be able to check if a promise resolves or rejects, regardless of the value that it produces, or if it even produces a value, it is irrelevant. In particular, i want to easily be able to easily check to make sure that a promise was not rejected. I don't care at all if it actually sent an error, undefined, or whatever, I just want to make sure it was not rejected. Previous issue referenced at jestjs/jest#5248
Possible solution:
I would like a matcher like expect(promise).toResolve() or expect(promise).not.toReject(). Right now, as far as I can tell, there is no simple way to go about asserting whether or not a promise has resolved or rejected without taking into account its value. I want to be able to assert this without regard to its response, the error message, or otherwise. @SimenB said that jestjs/jest#5919 adds support for async matchers, so this should be much more feasible now.
The text was updated successfully, but these errors were encountered: