lundi 10 février 2020

karma-mocha: promise exceeds timout

I have configured mocha as my testrunner for karma and until now it has worked just fine. Even some normal async functions have worked in the past. But now I want to test a custom HTML event and I get the error message Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves while waiting for the promise to resolve.

The oneEvent function in my code just returns a promise resolving to the emitted event.

The same line const event = await oneEvent(document.body, "colorChange") works in my app, meaning the event is definitely fired immediately and the promise gets resolved.

Some people in forums recommend to disable the timeout option via this.enableTimeouts(false). I did that but it didn't help neither. I have difficulties to debug this problem because other promises work fine. I hope somebody else has had a similar issue here. Thanks!

describe("ColorSlider", function() {
  this.timeout(10000) 
  it("check colorChange event", async () => {
    const event = await oneEvent(document.body, "colorChange")
    // assert(10, 10) // makes no difference
  })
})

Aucun commentaire:

Enregistrer un commentaire