Revert "don't swallow the first error if the second throws"

This reverts commit 13a4d19764.
This commit is contained in:
Simon Knott 2024-10-18 11:00:33 +02:00
parent 13a4d19764
commit d8d044e5ed
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -182,18 +182,15 @@ function createGlobalSetupTask(index: number, length: number): Task<TestRun> {
globalSetupFinished = true; globalSetupFinished = true;
}, },
teardown: async ({ config }) => { teardown: async ({ config }) => {
const errors = []; let firstError: any;
if (typeof globalSetupResult === 'function') if (typeof globalSetupResult === 'function')
try { await globalSetupResult(); } catch (error) { errors.push(error); } try { await globalSetupResult(); } catch (error) { firstError = error; }
if (globalSetupFinished) if (globalSetupFinished)
try { await teardownHook?.(config.config); } catch (error) { errors.push(error); } await teardownHook?.(config.config);
if (errors.length === 1) if (firstError)
throw errors[0]; throw firstError;
if (errors.length > 1)
throw new AggregateError(errors);
}, },
}; };
} }