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);
|
failedTestIds.add(test._id);
|
||||||
first = false;
|
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,
|
// Since we pretend that all remaining tests failed, there is nothing else to run,
|
||||||
// except for possible retries.
|
// except for possible retries.
|
||||||
remaining = [];
|
remaining = [];
|
||||||
|
|
|
||||||
|
|
@ -242,3 +242,19 @@ test('beforeAll hook should get retry index of the first test', async ({ runInli
|
||||||
'%%test-retry-1',
|
'%%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 a new issue