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; globalSetupFinished = true;
}, },
teardown: async ({ config }) => { teardown: async ({ config }) => {
let firstError: any;
if (typeof globalSetupResult === 'function') if (typeof globalSetupResult === 'function')
await globalSetupResult(); try { await globalSetupResult(); } catch (error) { firstError = error; }
if (globalSetupFinished) if (globalSetupFinished)
await teardownHook?.(config.config); await teardownHook?.(config.config);
if (firstError)
throw firstError;
}, },
}; };
} }

View file

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