From d205b091b5e11cb7fcf56049d7f69b5543e5fdd0 Mon Sep 17 00:00:00 2001 From: wenyutang-ms Date: Wed, 1 Apr 2026 14:36:40 +0800 Subject: [PATCH 1/2] test: enable Playwright trace on all E2E test runs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change trace from 'on-first-retry' to 'on' so every test run captures screenshots and DOM snapshots at each Playwright action. This makes debugging easier — especially when traces are reviewed by AI — since the full interaction flow is always available, not just on retries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- test/e2e/fixtures/baseTest.ts | 24 +++++++++++------------- test/e2e/playwright.config.ts | 6 ++++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/e2e/fixtures/baseTest.ts b/test/e2e/fixtures/baseTest.ts index 2d33a497..ffa761ab 100644 --- a/test/e2e/fixtures/baseTest.ts +++ b/test/e2e/fixtures/baseTest.ts @@ -136,24 +136,22 @@ export const test = base.extend({ await page.waitForTimeout(3_000); await dismissAllNotifications(page); - // 4. Optional tracing - if (testInfo.retry > 0 || !process.env.CI) { - await page.context().tracing.start({ screenshots: true, snapshots: true, title: testInfo.title }); - } + // 4. Start tracing — captures screenshots and DOM snapshots at every + // Playwright action so failures can be replayed step-by-step. + await page.context().tracing.start({ screenshots: true, snapshots: true, title: testInfo.title }); // ---- hand off to the test ---- await use(page); // ---- teardown ---- - // Save trace on failure/retry - if (testInfo.status !== "passed" || testInfo.retry > 0) { - const tracePath = testInfo.outputPath("trace.zip"); - try { - await page.context().tracing.stop({ path: tracePath }); - testInfo.attachments.push({ name: "trace", path: tracePath, contentType: "application/zip" }); - } catch { - // Tracing may not have been started - } + // Always save trace — on failure it's essential for debugging, + // on success it's useful for verifying the interaction flow. + const tracePath = testInfo.outputPath("trace.zip"); + try { + await page.context().tracing.stop({ path: tracePath }); + testInfo.attachments.push({ name: "trace", path: tracePath, contentType: "application/zip" }); + } catch { + // Tracing may not have been started } await electronApp.close(); diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index 91b6e7eb..b0710e00 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -22,8 +22,10 @@ export default defineConfig({ use: { // Automatically take a screenshot when a test fails. screenshot: "only-on-failure", - // Capture full trace on retry for deep debugging (includes screenshots, DOM snapshots, network). - trace: "on-first-retry", + // Capture full trace on every test run (includes screenshots, DOM + // snapshots, and network at each Playwright action). This makes it + // easy to diagnose failures — especially when reviewed by AI. + trace: "on", }, outputDir: path.join(__dirname, "..", "..", "test-results", "e2e"), }); From 236252367ac05721be5c4419a6d711e30cf5b721 Mon Sep 17 00:00:00 2001 From: wenyutang-ms Date: Wed, 1 Apr 2026 14:55:34 +0800 Subject: [PATCH 2/2] fix: use retain-on-failure in CI, remove manual tracing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review comments: - Use 'retain-on-failure' in CI to limit artifact size, 'on' locally - Remove manual tracing.start/stop from fixture — Playwright's built-in use.trace config handles it automatically, avoiding 'Tracing has been already started' conflicts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- test/e2e/fixtures/baseTest.ts | 16 ++++------------ test/e2e/playwright.config.ts | 10 ++++------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/test/e2e/fixtures/baseTest.ts b/test/e2e/fixtures/baseTest.ts index ffa761ab..83c7f8a9 100644 --- a/test/e2e/fixtures/baseTest.ts +++ b/test/e2e/fixtures/baseTest.ts @@ -136,23 +136,15 @@ export const test = base.extend({ await page.waitForTimeout(3_000); await dismissAllNotifications(page); - // 4. Start tracing — captures screenshots and DOM snapshots at every - // Playwright action so failures can be replayed step-by-step. - await page.context().tracing.start({ screenshots: true, snapshots: true, title: testInfo.title }); + // Tracing is handled by Playwright's built-in `use.trace` config + // (see playwright.config.ts). No manual tracing.start/stop needed. // ---- hand off to the test ---- await use(page); // ---- teardown ---- - // Always save trace — on failure it's essential for debugging, - // on success it's useful for verifying the interaction flow. - const tracePath = testInfo.outputPath("trace.zip"); - try { - await page.context().tracing.stop({ path: tracePath }); - testInfo.attachments.push({ name: "trace", path: tracePath, contentType: "application/zip" }); - } catch { - // Tracing may not have been started - } + // Trace saving is handled automatically by Playwright's `use.trace` + // config — no manual tracing.stop() needed here. await electronApp.close(); diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index b0710e00..4af6182b 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -20,12 +20,10 @@ export default defineConfig({ }, globalSetup: path.join(__dirname, "globalSetup.ts"), use: { - // Automatically take a screenshot when a test fails. - screenshot: "only-on-failure", - // Capture full trace on every test run (includes screenshots, DOM - // snapshots, and network at each Playwright action). This makes it - // easy to diagnose failures — especially when reviewed by AI. - trace: "on", + // Capture full trace on every test run locally (includes screenshots, + // DOM snapshots, and network at each Playwright action). In CI, + // retain traces only for failing tests to limit artifact size. + trace: process.env.CI ? "retain-on-failure" : "on", }, outputDir: path.join(__dirname, "..", "..", "test-results", "e2e"), });