Skip to content

Commit

Permalink
Tests/LibWeb: Finish async test when an error is caught
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rmg-x committed Jan 16, 2025
1 parent 3d20587 commit 3a7e2d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Tests/LibWeb/Text/input/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
__finishTest();
});
});
}

Expand Down

0 comments on commit 3a7e2d4

Please sign in to comment.