test: add a test that fixture error after timeout is not a fatal error (#12141)

This commit is contained in:
Dmitry Gozman 2022-02-15 18:05:20 -08:00 committed by GitHub
parent 65697d64be
commit 85cb3c9713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View File

@ -455,3 +455,27 @@ test('should not report fixture teardown error twice', async ({ runInlineTest })
expect(stripAnsi(result.output)).toContain(`throw new Error('Oh my error')`);
expect(countTimes(result.output, 'Oh my error')).toBe(2);
});
test('should handle fixture teardown error after test timeout and continue', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.spec.ts': `
const test = pwt.test.extend({
fixture: async ({ }, use) => {
await use();
throw new Error('Oh my error');
},
});
test('bad', async ({ fixture }) => {
test.setTimeout(100);
await new Promise(f => setTimeout(f, 500));
});
test('good', async ({}) => {
});
`,
}, { reporter: 'list', workers: '1' });
expect(result.exitCode).toBe(1);
expect(result.failed).toBe(1);
expect(result.passed).toBe(1);
expect(result.output).toContain('Timeout of 100ms exceeded');
expect(result.output).toContain('Error: Oh my error');
});

View File

@ -20,14 +20,14 @@ import { startHtmlReportServer } from '../../packages/playwright-test/lib/report
const test = baseTest.extend<{ showReport: () => Promise<void> }>({
showReport: async ({ page }, use, testInfo) => {
let server: HttpServer;
let server: HttpServer | undefined;
await use(async () => {
const reportFolder = testInfo.outputPath('playwright-report');
server = startHtmlReportServer(reportFolder);
const location = await server.start();
await page.goto(location);
});
await server.stop();
await server?.stop();
}
});