Skip to content

Commit cdd189c

Browse files
wenytang-msCopilot
andauthored
test: enable Playwright trace on all E2E test runs (#987)
* test: enable Playwright trace on all E2E test runs 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> * fix: use retain-on-failure in CI, remove manual tracing 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> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3a886bd commit cdd189c

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

test/e2e/fixtures/baseTest.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,15 @@ export const test = base.extend<TestFixtures>({
136136
await page.waitForTimeout(3_000);
137137
await dismissAllNotifications(page);
138138

139-
// 4. Optional tracing
140-
if (testInfo.retry > 0 || !process.env.CI) {
141-
await page.context().tracing.start({ screenshots: true, snapshots: true, title: testInfo.title });
142-
}
139+
// Tracing is handled by Playwright's built-in `use.trace` config
140+
// (see playwright.config.ts). No manual tracing.start/stop needed.
143141

144142
// ---- hand off to the test ----
145143
await use(page);
146144

147145
// ---- teardown ----
148-
// Save trace on failure/retry
149-
if (testInfo.status !== "passed" || testInfo.retry > 0) {
150-
const tracePath = testInfo.outputPath("trace.zip");
151-
try {
152-
await page.context().tracing.stop({ path: tracePath });
153-
testInfo.attachments.push({ name: "trace", path: tracePath, contentType: "application/zip" });
154-
} catch {
155-
// Tracing may not have been started
156-
}
157-
}
146+
// Trace saving is handled automatically by Playwright's `use.trace`
147+
// config — no manual tracing.stop() needed here.
158148

159149
await electronApp.close();
160150

test/e2e/playwright.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export default defineConfig({
2020
},
2121
globalSetup: path.join(__dirname, "globalSetup.ts"),
2222
use: {
23-
// Automatically take a screenshot when a test fails.
24-
screenshot: "only-on-failure",
25-
// Capture full trace on retry for deep debugging (includes screenshots, DOM snapshots, network).
26-
trace: "on-first-retry",
23+
// Capture full trace on every test run locally (includes screenshots,
24+
// DOM snapshots, and network at each Playwright action). In CI,
25+
// retain traces only for failing tests to limit artifact size.
26+
trace: process.env.CI ? "retain-on-failure" : "on",
2727
},
2828
outputDir: path.join(__dirname, "..", "..", "test-results", "e2e"),
2929
});

0 commit comments

Comments
 (0)