Skip to content

Commit 2362523

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

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 & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,15 @@ export const test = base.extend<TestFixtures>({
136136
await page.waitForTimeout(3_000);
137137
await dismissAllNotifications(page);
138138

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 });
139+
// Tracing is handled by Playwright's built-in `use.trace` config
140+
// (see playwright.config.ts). No manual tracing.start/stop needed.
142141

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

146145
// ---- teardown ----
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
155-
}
146+
// Trace saving is handled automatically by Playwright's `use.trace`
147+
// config — no manual tracing.stop() needed here.
156148

157149
await electronApp.close();
158150

test/e2e/playwright.config.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +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 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",
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",
2927
},
3028
outputDir: path.join(__dirname, "..", "..", "test-results", "e2e"),
3129
});

0 commit comments

Comments
 (0)