question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught errors from promises getting swallowed when running in Jest

See original GitHub issue

Example:

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:closed
  • Created 6 years ago
  • Comments:29 (29 by maintainers)

github_iconTop GitHub Comments

1reaction
pelotomcommented, Aug 14, 2017

Yep, I just discovered I could reproduce in the browser too 😃

Cool, thanks for the pointer, I might try against that patch.

0reactions
jayphelpscommented, Aug 15, 2017

You’re welcome! Glad you found a solution. 🤘

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found