From b5ebdfc04b0c828d635a34bcbdbd6b8204c3b7e5 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:38:01 -0600 Subject: [PATCH] feat: add logic for capturing and abandoning trace when using on-first-failure mode --- packages/playwright/src/worker/testTracing.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.ts index 93cf5daad5..80949da792 100644 --- a/packages/playwright/src/worker/testTracing.ts +++ b/packages/playwright/src/worker/testTracing.ts @@ -54,6 +54,7 @@ export class TestTracing { if (this._options?.mode === 'retain-on-failure') capture = true; if (this._options?.mode === 'on-first-retry' && this._testInfo.retry === 1) capture = true; if (this._options?.mode === 'on-all-retries' && this._testInfo.retry > 0) capture = true; + if (this._options?.mode === 'on-first-failure' && this._testInfo.retry === 0) capture = true; return capture && !process.env.PW_TEST_DISABLE_TRACING; } @@ -119,7 +120,8 @@ export class TestTracing { return; const testFailed = this._testInfo.status !== this._testInfo.expectedStatus; - const shouldAbandonTrace = !testFailed && this._options.mode === 'retain-on-failure'; + const shouldAbandonTrace = !testFailed && (this._options.mode === 'retain-on-failure' || this._options.mode === 'on-first-failure'); + if (shouldAbandonTrace) { for (const file of this._temporaryTraceFiles) await fs.promises.unlink(file).catch(() => {});