Skip to content

Commit d205b09

Browse files
wenytang-msCopilot
andcommitted
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>
1 parent c942b47 commit d205b09

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

test/e2e/fixtures/baseTest.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,22 @@ 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+
// 4. Start tracing — captures screenshots and DOM snapshots at every
140+
// Playwright action so failures can be replayed step-by-step.
141+
await page.context().tracing.start({ screenshots: true, snapshots: true, title: testInfo.title });
143142

144143
// ---- hand off to the test ----
145144
await use(page);
146145

147146
// ---- 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-
}
147+
// Always save trace — on failure it's essential for debugging,
148+
// on success it's useful for verifying the interaction flow.
149+
const tracePath = testInfo.outputPath("trace.zip");
150+
try {
151+
await page.context().tracing.stop({ path: tracePath });
152+
testInfo.attachments.push({ name: "trace", path: tracePath, contentType: "application/zip" });
153+
} catch {
154+
// Tracing may not have been started
157155
}
158156

159157
await electronApp.close();

test/e2e/playwright.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ export default defineConfig({
2222
use: {
2323
// Automatically take a screenshot when a test fails.
2424
screenshot: "only-on-failure",
25-
// Capture full trace on retry for deep debugging (includes screenshots, DOM snapshots, network).
26-
trace: "on-first-retry",
25+
// Capture full trace on every test run (includes screenshots, DOM
26+
// snapshots, and network at each Playwright action). This makes it
27+
// easy to diagnose failures — especially when reviewed by AI.
28+
trace: "on",
2729
},
2830
outputDir: path.join(__dirname, "..", "..", "test-results", "e2e"),
2931
});

0 commit comments

Comments
 (0)