-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Errors thrown in event handlers are not propagating to tests #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the detailed report. This is unfortunately not possible since it's inherent to how it works in the DOM. dispatching an event never throws if a function that handled that error throws. In other terms
-- https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
This bit being the important part. Maybe you can find a solution to your underlying problem on StackOverflow. |
@eps1lon did you manage to find a solution in how to test this? |
@charklewis I didn't look for one. You probably want to ask the author of the issue instead. |
@charklewis my solution was not to throw at all. As standard suggests the error is not propagated to the caller, which means the exception should be caught in the callback handler and be dealt with there directly (e.g. with window alert if the message is client relevant) |
Ah ok no worries, makes sense. I have done the same! Thanks for the prompt reply. |
Hey folks,
I'm not sure if this is an issue for this library, react or even jest-dom, so I'm starting here so where it leads:
for the following component
the following test does not pass
somehow the error is being swallowed on the way, I have tried almost all combinations with wrapping in act with async/awaits and promises to no avail
any help would be appreciated.
Reproduction repro
The text was updated successfully, but these errors were encountered: