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
How can I tests these two handlers in Jasmine? I don't see a way to disable uncaughtException in Jasmine. I did programmatically remove all uncaughtException in my test using (process.removeListener), set up my uncaughtException handler, and my exception handler caught the exception, but the test still failed in Jasmine.
It depends somewhat on what exactly you want to test. I can think of a few possibilities:
The behavior of the error handlers themselves
Whether the error handlers were installed
The integration of the error handlers with other software (possibly including the Node runtime)
For # 1, I suggest exposing the error handlers themselves as named functions and calling them directly from the test. For # 2, you might be able to spy on process.on and assert that it got called as expected. I don't think there's currently a way to accomplish # 3. I'm open to suggestions.
BTW, the reason your test is failing is because it sets up uncaughtException handlers but then triggers an unhandled rejection rather than an uncaught exception. That said, I don't recommend removing Jasmine's handlers like that. The most likely problem that you'd run into is subsequent tests passing when they should have failed. But in general all bets are off once you start tinkering with Jasmine's internals.
How can I tests these two handlers in Jasmine? I don't see a way to disable uncaughtException in Jasmine. I did programmatically remove all uncaughtException in my test using (process.removeListener), set up my uncaughtException handler, and my exception handler caught the exception, but the test still failed in Jasmine.
uncaughtException handler:
Test
The text was updated successfully, but these errors were encountered: