From 8e83bfc6cf0bd2ba964d918479be2d1a43e76846 Mon Sep 17 00:00:00 2001 From: epszaw Date: Sun, 23 Feb 2025 15:03:01 +0100 Subject: [PATCH] add tests for playwright trace attachments --- .../test/spec/attachments.spec.ts | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/allure-playwright/test/spec/attachments.spec.ts b/packages/allure-playwright/test/spec/attachments.spec.ts index d72a81a39..349f0fdaf 100644 --- a/packages/allure-playwright/test/spec/attachments.spec.ts +++ b/packages/allure-playwright/test/spec/attachments.spec.ts @@ -60,3 +60,52 @@ it("adds snapshots correctly and provide a screenshot diff", async () => { source: expect.stringMatching(/.*\.imagediff/), }); }); + +it("adds trace to the report as an attachment", async () => { + const { tests } = await runPlaywrightInlineTest({ + "sample.test.js": ` + import test from '@playwright/test'; + + test('should do nothing', async ({ page }, testInfo) => { + await page.goto('https://allurereport.org'); + }); + `, + "playwright.config.js": ` + import { defineConfig } from "@playwright/test"; + + export default { + outputDir: "./test-results", + reporter: [ + [ + require.resolve("allure-playwright"), + { + resultsDir: "./allure-results", + detail: false, + }, + ], + ["dot"], + ], + projects: [ + { + name: "project", + }, + ], + use: { + trace: "on", + } + }; + `, + }); + + expect(tests[0].steps).toHaveLength(1); + expect(tests[0].steps[0]).toMatchObject({ + name: "trace", + attachments: [ + expect.objectContaining({ + name: "trace", + type: "application/zip", + source: expect.stringMatching(/.*\.zip/), + }), + ], + }); +});