mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-13 17:14:02 +03:00
fix(test runner): do not swallow afterAll failure (#8099)
This commit is contained in:
parent
29f7dfa3ee
commit
e638c4597f
@ -144,6 +144,12 @@ export class Dispatcher {
|
||||
failedTestIds.add(test._id);
|
||||
first = false;
|
||||
}
|
||||
if (first) {
|
||||
// We had a fatal error after all tests have passed - most likely in the afterAll hook.
|
||||
// Let's just fail the test run.
|
||||
this._hasWorkerErrors = true;
|
||||
this._reporter.onError?.(params.fatalError);
|
||||
}
|
||||
// Since we pretend that all remaining tests failed, there is nothing else to run,
|
||||
// except for possible retries.
|
||||
remaining = [];
|
||||
|
@ -242,3 +242,19 @@ test('beforeAll hook should get retry index of the first test', async ({ runInli
|
||||
'%%test-retry-1',
|
||||
]);
|
||||
});
|
||||
|
||||
test('afterAll exception should fail the run', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = pwt;
|
||||
test.afterAll(() => {
|
||||
throw new Error('From the afterAll');
|
||||
});
|
||||
test('passed', () => {
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.output).toContain('From the afterAll');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user