From bc66311a05cb0925b8b970b8c5b4b5db56e375fe Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Fri, 20 Dec 2024 11:42:58 +0100 Subject: [PATCH] make _attachScreenshot use attach() --- packages/playwright/src/index.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index 9680f3bcf7..1e70bfc151 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -638,7 +638,7 @@ class ArtifactsRecorder { try { const screenshotPath = this._createScreenshotAttachmentPath(); await fs.promises.rename(file, screenshotPath); - this._attachScreenshot(screenshotPath); + await this._attachScreenshot(screenshotPath); } catch { } } @@ -665,19 +665,14 @@ class ArtifactsRecorder { if (temporary) this._temporaryScreenshots.push(screenshotPath); else - this._attachScreenshot(screenshotPath); + await this._attachScreenshot(screenshotPath); } catch { // Screenshot may fail, just ignore. } } - private _attachScreenshot(screenshotPath: string) { - const step = this._testInfo._addStep({ - title: `attach "screenshot"`, - category: 'attach', - }); - step.attachments.push({ name: 'screenshot', path: screenshotPath, contentType: 'image/png' }); - step.complete({}); + private async _attachScreenshot(screenshotPath: string) { + await this._testInfo.attach('screenshot', { path: screenshotPath, contentType: 'image/png' }); } private async _screenshotOnTestFailure() {