You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently vitest fails a test run if it detects an unhandled rejection having been thrown:
Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
However, sometimes this is a desireable behaviour, especially when we are testing global unhandled rejection handlers.
Suggested solution
Several options are possible:
Only report as a problem unhandled rejections that were not handled during the test execution (e. g. if there is no `process.on('unhandledRejection' handler that would consume the event);
Make it possible to mark tests as expecting the unhandled rejections (e. g. syntax similar to expect.assertions(1) - expect.unhandledRejections(1))
I'm interested in this as well. With event handlers and callbacks in general, errors don't always make it back to the original call site, so they're thrown and uncaught/unhandled.
It'd be great if Vitest had an easy way "expect" these.
Last time I needed this I had to register my own unhandled rejection listener, probably breaking Vitest's own. Example:
@sheremet-va It's perfectly fine to expect user to register their own unhandedRejection handler, key problem is that it doesn't seem possible at the moment, vitest reports the test as failed anyway
Clear and concise description of the problem
Currently vitest fails a test run if it detects an unhandled rejection having been thrown:
However, sometimes this is a desireable behaviour, especially when we are testing global unhandled rejection handlers.
Suggested solution
Several options are possible:
expect.assertions(1)
-expect.unhandledRejections(1)
)Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: