I’m testing a component that relies on an event emitter using Promises with Mocha+Chai. Here’s my current test code:
On the console, I’m encountering an UnhandledPromiseRejectionWarning even though the reject function is being called. The warning message appears immediately with AssertionError: Promise error, and then, after about 2 seconds, I get:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test. The issue is puzzling because the catch callback is executed (suggesting that reject is being called), but it seems like the assert.isNotOk(error…) is causing problems. If I comment out assert.isNotOk(error…), the test runs without warning and completes as expected.
Can someone help me understand why this UnhandledPromiseRejectionWarning is occurring and why commenting out the assertion affects the test execution?