diff --git a/test/e2e/fixtures/baseTest.ts b/test/e2e/fixtures/baseTest.ts index 2d33a497..83c7f8a9 100644 --- a/test/e2e/fixtures/baseTest.ts +++ b/test/e2e/fixtures/baseTest.ts @@ -136,25 +136,15 @@ 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 }); - } + // 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 ---- - // 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 - } - } + // 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 91b6e7eb..4af6182b 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -20,10 +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 retry for deep debugging (includes screenshots, DOM snapshots, network). - trace: "on-first-retry", + // 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"), });