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
chore: do not store empty step.attachments[] in trace (#34579)
Yury Semikhatskyf1a392f84421
diff --git a/packages/playwright/src/reporters/teleEmitter.ts b/packages/playwright/src/reporters/teleEmitter.tsindex eadd2b05a5..76fc1490a6 100644--- a/packages/playwright/src/reporters/teleEmitter.ts+++ b/packages/playwright/src/reporters/teleEmitter.ts@@ -256,7 +256,7 @@ export class TeleReporterEmitter implements ReporterV2 {id: (step as any)[this._idSymbol],duration: step.duration,error: step.error,- attachments: step.attachments.map(a => result.attachments.indexOf(a)),+ attachments: step.attachments.length ? step.attachments.map(a => result.attachments.indexOf(a)) : undefined,annotations: step.annotations.length ? step.annotations : undefined,};}diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.tsindex 15bb17db06..e154d6a649 100644--- a/packages/playwright/src/worker/testTracing.ts+++ b/packages/playwright/src/worker/testTracing.ts@@ -278,6 +278,8 @@ export class TestTracing {}function serializeAttachments(attachments: Attachment[]): trace.AfterActionTraceEvent['attachments'] {+ if (attachments.length === 0)+ return undefined;return attachments.filter(a => a.name !== 'trace').map(a => {return {name: a.name,diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.tsindex 045ad6d419..88995c6f1c 100644--- a/tests/playwright-test/playwright.trace.spec.ts+++ b/tests/playwright-test/playwright.trace.spec.ts@@ -761,7 +761,7 @@ test('should not throw when screenshot on failure fails', async ({ runInlineTestexpect(result.exitCode).toBe(0);expect(result.passed).toBe(1);const trace = await parseTrace(testInfo.outputPath('test-results', 'a-has-download-page', 'trace.zip'));- const attachedScreenshots = trace.actions.flatMap(a => a.attachments);+ const attachedScreenshots = trace.actions.filter(a => a.attachments).flatMap(a => a.attachments);// One screenshot for the page, no screenshot for the download page since it should have failed.expect(attachedScreenshots.length).toBe(1);});