mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(test runner): afterAll error should not mask beforeAll error (#8358)
This commit is contained in:
parent
d3a703478b
commit
f9b87268a7
@ -162,6 +162,7 @@ export class WorkerRunner extends EventEmitter {
|
||||
// TODO: separate timeout for beforeAll modifiers?
|
||||
const result = await raceAgainstDeadline(this._fixtureRunner.resolveParametersAndRunHookOrTest(beforeAllModifier.fn, this._workerInfo, undefined), this._deadline());
|
||||
if (result.timedOut) {
|
||||
if (!this._fatalError)
|
||||
this._fatalError = serializeError(new Error(`Timeout of ${this._project.config.timeout}ms exceeded while running ${beforeAllModifier.type} modifier`));
|
||||
this.stop();
|
||||
}
|
||||
@ -375,7 +376,7 @@ export class WorkerRunner extends EventEmitter {
|
||||
if (testInfo.status !== 'passed' && testInfo.status !== 'skipped') {
|
||||
if (test._type === 'test')
|
||||
this._failedTestId = testId;
|
||||
else
|
||||
else if (!this._fatalError)
|
||||
this._fatalError = testInfo.error;
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@ -401,3 +401,22 @@ test('afterEach failure should not prevent afterAll', async ({ runInlineTest })
|
||||
'%%afterAll',
|
||||
]);
|
||||
});
|
||||
|
||||
test('afterAll error should not mask beforeAll', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = pwt;
|
||||
test.beforeAll(() => {
|
||||
throw new Error('from beforeAll');
|
||||
});
|
||||
test.afterAll(() => {
|
||||
throw new Error('from afterAll');
|
||||
})
|
||||
test('test', () => {
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.failed).toBe(1);
|
||||
expect(result.output).toContain('from beforeAll');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user