diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.ts index c820476f27..d017040f7f 100644 --- a/packages/playwright/src/worker/testTracing.ts +++ b/packages/playwright/src/worker/testTracing.ts @@ -48,15 +48,14 @@ export class TestTracing { } private _shouldCaptureTrace() { - let capture = false; + if (process.env.PW_TEST_DISABLE_TRACING) return false; + if (this._options?.mode === 'on') return true; + if (this._options?.mode === 'retain-on-failure') return true; + if (this._options?.mode === 'on-first-retry' && this._testInfo.retry === 1) return true; + if (this._options?.mode === 'on-all-retries' && this._testInfo.retry > 0) return true; + if (this._options?.mode === 'retain-on-first-failure' && this._testInfo.retry === 0) return true; - if (this._options?.mode === 'on') capture = true; - 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 === 'retain-on-first-failure' && this._testInfo.retry === 0) capture = true; - - return capture && !process.env.PW_TEST_DISABLE_TRACING; + return false; } async startIfNeeded(value: TraceFixtureValue) {