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: make sure trace is recorded for custom fixtures (#23418)
Dmitry Gozman5d5314e006ec
diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.tsindex 418795d681..bd95a7c3aa 100644--- a/tests/playwright-test/playwright.trace.spec.ts+++ b/tests/playwright-test/playwright.trace.spec.ts@@ -15,7 +15,7 @@*/import { test, expect } from './playwright-test-fixtures';-import { parseTrace } from '../config/utils';+import { parseTrace, parseTraceRaw } from '../config/utils';import fs from 'fs';test.describe.configure({ mode: 'parallel' });@@ -578,3 +578,32 @@ test('should opt out of attachments', async ({ runInlineTest, server }, testInfoexpect(trace.actions[1].attachments).toEqual(undefined);expect([...trace.resources.keys()].filter(f => f.startsWith('resources/'))).toHaveLength(0);});++test('should record with custom page fixture', async ({ runInlineTest }, testInfo) => {+ const result = await runInlineTest({+ 'a.spec.ts': `+ import { test as base, expect } from '@playwright/test';++ const test = base.extend({+ myPage: async ({ browser }, use) => {+ await use(await browser.newPage());+ },+ });++ test.use({ trace: 'on' });++ test('fails', async ({ myPage }, testInfo) => {+ await myPage.setContent('hello');+ throw new Error('failure!');+ });+ `,+ }, { workers: 1 });++ expect(result.exitCode).toBe(1);+ expect(result.failed).toBe(1);+ expect(result.output).toContain('failure!');+ const trace = await parseTraceRaw(testInfo.outputPath('test-results', 'a-fails', 'trace.zip'));+ expect(trace.events).toContainEqual(expect.objectContaining({+ type: 'frame-snapshot',+ }));+});