rejects doesn't work
See original GitHub issueI’ve tried to use the await expect(...).rejects
function as documented in https://facebook.github.io/jest/docs/en/tutorial-async.html
However rejects
it simply doesn’t work at all.
This is an error example:
expect(received).rejects.toHaveProperty()
Expected received Promise to reject, instead it resolved to value
undefined
at Object.<anonymous> (node_modules/expect/build/index.js:182:9)
at step (node_modules/expect/build/index.js:43:727)
at node_modules/expect/build/index.js:43:887
Of course the promise in that case was a rejection but it wasn’t seen as so.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Promise reject not working inside of callback - Stack Overflow
I'm following the common pattern of handling callbacks that return something, but yeah this might not work for promises. I've always had it...
Read more >Rejection and How to Handle It (for Teens) - Kids Health
Feeling rejected is the opposite of feeling accepted. But being rejected (and we all will be at times) doesn't mean someone isn't liked,...
Read more >Promise.reject() - JavaScript - MDN Web Docs
The Promise.reject() method returns a Promise object that is rejected with a given reason.
Read more >JavaScript Promise Tutorial – How to Resolve or Reject ...
A Promise is a special JavaScript object. It produces a value after an asynchronous (aka, async) operation completes successfully, or an error ...
Read more >Frequently Asked Questions - Jasmine Documentation
How can I configure a spy to return a rejected promise without triggering an ... However, that doesn't work with arrow functions, because...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That example works correctly: https://repl.it/repls/HumongousKnottyMilkweedbug. It fails because the
toEqual
part is wrong, but it rejects correctly - there is no@SimenB I’ve added it.