1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

LibJS/Tests: Catch exceptions in describe() itself

Otherwise exceptions thrown in that state would simply terminate the
test.
This commit is contained in:
Ali Mohammad Pur 2021-06-04 03:23:33 +04:30 committed by Ali Mohammad Pur
parent d7ba15371b
commit 09cf1040ef

View file

@ -441,7 +441,15 @@ class ExpectationError extends Error {
describe = (message, callback) => {
suiteMessage = message;
callback();
if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {};
try {
callback();
} catch (e) {
__TestResults__[suiteMessage][defaultSuiteMessage] = {
result: "fail",
details: String(e),
};
}
suiteMessage = defaultSuiteMessage;
};