happy-dom icon indicating copy to clipboard operation
happy-dom copied to clipboard

Jest environment could detect some errors it is currently silencing

Open yjaaidi opened this issue 11 months ago • 0 comments

The following tests will not show any error when using happy-dom environment:

test('leak microtask', () => {
  queueMicrotask(() => expect(1).toBe(2));
});

test('leak timer', () => {
  setTimeout(() => expect(1).toBe(2), 1000);
});

It would be nice if the environment could detect pending timers or flush (until timeout) when torn down. This could be achieved with something like await this.global.happyDOM.waitUntilComplete() in the teardown.

I'll be happy to help with a PR.

Cf. https://github.com/jestjs/jest/issues/14984

yjaaidi avatar Mar 21 '24 15:03 yjaaidi