Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: add a test that fixture error after timeout is not a fatal error (#12141)
Dmitry Gozman85cb3c9713dd
diff --git a/tests/playwright-test/fixture-errors.spec.ts b/tests/playwright-test/fixture-errors.spec.tsindex 4b108d4ce1..03ba3d5ea4 100644--- a/tests/playwright-test/fixture-errors.spec.ts+++ b/tests/playwright-test/fixture-errors.spec.ts@@ -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');+});diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.tsindex 64ac0dbffe..d56bd15b79 100644--- a/tests/playwright-test/reporter-html.spec.ts+++ b/tests/playwright-test/reporter-html.spec.ts@@ -20,14 +20,14 @@ import { startHtmlReportServer } from '../../packages/playwright-test/lib/reportconst 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();}});