make behaviour congruent for globalTeardown

This commit is contained in:
Simon Knott 2024-10-18 08:53:39 +02:00
parent a72ec6e824
commit 9b785662f6
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 7 additions and 2 deletions

View file

@ -182,10 +182,15 @@ function createGlobalSetupTask(index: number, length: number): Task<TestRun> {
globalSetupFinished = true;
},
teardown: async ({ config }) => {
let firstError: any;
if (typeof globalSetupResult === 'function')
await globalSetupResult();
try { await globalSetupResult(); } catch (error) { firstError = error; }
if (globalSetupFinished)
await teardownHook?.(config.config);
if (firstError)
throw firstError;
},
};
}

View file

@ -422,7 +422,7 @@ test('globalSetup should support multiple', async ({ runInlineTest }) => {
'globalSetup3Function',
'globalTeardown2',
'globalSetup1Function',
// 'globalTeardown1' is missing, because globalSetup1Function errored out.
'globalTeardown1',
]);
expect(result.output).toContain('Error: kaboom');
});