From 606860d250f81eb6652aa272ab5e63fd3d563dd4 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 16 Oct 2024 09:00:00 +0200 Subject: [PATCH] remove attachment steps for everything except explicit testInfo.attach() --- packages/playwright/src/worker/testInfo.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.ts index 378b32524f..b3fe2172ac 100644 --- a/packages/playwright/src/worker/testInfo.ts +++ b/packages/playwright/src/worker/testInfo.ts @@ -192,7 +192,7 @@ export class TestInfoImpl implements TestInfo { this._attachmentsPush = this.attachments.push.bind(this.attachments); this.attachments.push = (...attachments: TestInfo['attachments']) => { for (const a of attachments) - this._attach(a.name, a); + this._attach(a); return this.attachments.length; }; @@ -398,14 +398,16 @@ export class TestInfoImpl implements TestInfo { // ------------ TestInfo methods ------------ async attach(name: string, options: { path?: string, body?: string | Buffer, contentType?: string } = {}) { - this._attach(name, await normalizeAndSaveAttachment(this.outputPath(), name, options)); - } - - private _attach(name: string, attachment: TestInfo['attachments'][0]) { const step = this._addStep({ title: `attach "${name}"`, category: 'attach', }); + const attachment = await normalizeAndSaveAttachment(this.outputPath(), name, options); + this._attach(attachment); + step.complete({ attachments: [attachment] }); + } + + private _attach(attachment: TestInfo['attachments'][0]) { this._attachmentsPush(attachment); this._onAttach({ testId: this.testId, @@ -414,7 +416,6 @@ export class TestInfoImpl implements TestInfo { path: attachment.path, body: attachment.body?.toString('base64') }); - step.complete({ attachments: [attachment] }); } outputPath(...pathSegments: string[]){