Tests/LibWeb: Finish async test when an error is caught

This catches errors that occur within async tests so that we fail faster
rather than timing out due to `done()` not being called.

We use `Promise.resolve()` because `f` isn't guaranteed to be an async
function.
This commit is contained in:
rmg-x 2025-01-15 19:12:56 -06:00 committed by Andrew Kaster
commit 0de910784e
Notes: github-actions[bot] 2025-02-05 20:28:23 +00:00

View file

@ -86,7 +86,10 @@ function asyncTest(f) {
__finishTest();
};
document.addEventListener("DOMContentLoaded", () => {
f(done);
Promise.resolve(f(done)).catch(error => {
println(`Caught error while running async test: ${error}`);
done();
});
});
}