mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-13 17:14:02 +03:00
test: add a test that fixture error after timeout is not a fatal error (#12141)
This commit is contained in:
parent
65697d64be
commit
85cb3c9713
@ -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');
|
||||
});
|
||||
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user