Uncaught errors from promises getting swallowed when running in Jest
See original GitHub issueExample:
const ohNoEpic = action$ => action$
.ofType('OH_NO') // where OH_NO is some real action type that will be matched
.mergeMap(() =>
Observable.fromPromise(new Promise(() => { throw Error('oh no') }))
)
In the browser this yields a stack trace on the console… in Jest, nothing happens. If the promise was a real epic that was being tested, the test would eventually time out, with no useful error message being printed.
Issue Analytics
- State:
- Created 6 years ago
- Comments:29 (29 by maintainers)
Top Results From Across the Web
How do I fail a test in Jest when an uncaught promise rejection ...
The code I'm testing is throwing errors within promises resulting in an UnhandledPromiseRejectionWarning message being logged to the console.
Read more >Are ES6 Promises swallowing your errors? : r/javascript - Reddit
Anyhow, this TypeError was eaten and I had to wrap the body of my promise with a try/catch block, which rejects in case...
Read more >triggeruncaughtexception(err true /* frompromise */) node 16 - You ...
Jest on promises: triggerUncaughtException(err, true /* fromPromise */) ... I have just found a very misleading error being thrown by node v16.14.2 because ......
Read more >Are JavaScript Promises swallowing your errors?
The obvious way to go about fixing this is to add an extra catch statement to the end of each of your promise...
Read more >Using promises - JavaScript - MDN Web Docs
Importantly, if doSomethingCritical() fails, its error is caught by the final (outer) catch only, and does not get swallowed by the inner catch ......
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 Free
Top 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
Yep, I just discovered I could reproduce in the browser too 😃
Cool, thanks for the pointer, I might try against that patch.
You’re welcome! Glad you found a solution. 🤘