diff --git a/packages/playwright-core/src/client/browserType.ts b/packages/playwright-core/src/client/browserType.ts index 789203cc00..1932d6e2d8 100644 --- a/packages/playwright-core/src/client/browserType.ts +++ b/packages/playwright-core/src/client/browserType.ts @@ -67,7 +67,6 @@ export class BrowserType extends ChannelOwner imple options = { ...this._playwright._defaultLaunchOptions, ...options }; const launchOptions: channels.BrowserTypeLaunchParams = { ...options, - tracesDir: options.tracesDir ?? this._playwright._defaultTracesDir, ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined, ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs), env: options.env ? envObjectToArray(options.env) : undefined, diff --git a/packages/playwright-core/src/client/fetch.ts b/packages/playwright-core/src/client/fetch.ts index 3d49b72b8d..121bba4d9a 100644 --- a/packages/playwright-core/src/client/fetch.ts +++ b/packages/playwright-core/src/client/fetch.ts @@ -74,12 +74,12 @@ export class APIRequest implements api.APIRequest { ...options, extraHTTPHeaders: options.extraHTTPHeaders ? headersObjectToArray(options.extraHTTPHeaders) : undefined, storageState, - tracesDir: this._playwright._defaultTracesDir, + tracesDir: this._playwright._defaultLaunchOptions?.tracesDir, // We do not expose tracesDir in the API, so do not allow options to accidentally override it. clientCertificates: await toClientCertificatesProtocol(options.clientCertificates), })).request); this._contexts.add(context); context._request = this; - context._tracing._tracesDir = this._playwright._defaultTracesDir; + context._tracing._tracesDir = this._playwright._defaultLaunchOptions?.tracesDir; await context._instrumentation.runAfterCreateRequestContext(context); return context; } diff --git a/packages/playwright-core/src/client/playwright.ts b/packages/playwright-core/src/client/playwright.ts index 921de3a7c6..078e31259d 100644 --- a/packages/playwright-core/src/client/playwright.ts +++ b/packages/playwright-core/src/client/playwright.ts @@ -42,7 +42,6 @@ export class Playwright extends ChannelOwner { _defaultContextOptions?: BrowserContextOptions; _defaultContextTimeout?: number; _defaultContextNavigationTimeout?: number; - _defaultTracesDir?: string; constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.PlaywrightInitializer) { super(parent, type, guid, initializer); diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index 1a2e4cbf93..f3e11ddfaf 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -83,11 +83,11 @@ const playwrightFixtures: Fixtures = ({ options.headless = headless; if (channel !== undefined) options.channel = channel; - playwright._defaultTracesDir = tracing().tracesDir(); + playwright._defaultLaunchOptions = options; + playwright._defaultLaunchOptions.tracesDir = tracing().tracesDir(); await use(options); playwright._defaultLaunchOptions = undefined; - playwright._defaultTracesDir = undefined; }, { scope: 'worker', auto: true, box: true }], browser: [async ({ playwright, browserName, _browserOptions, connectOptions, _reuseContext }, use, testInfo) => { @@ -234,12 +234,10 @@ const playwrightFixtures: Fixtures = ({ playwright._defaultContextOptions = _combinedContextOptions; playwright._defaultContextTimeout = actionTimeout || 0; playwright._defaultContextNavigationTimeout = navigationTimeout || 0; - playwright._defaultTracesDir = tracing().tracesDir(); await use(); playwright._defaultContextOptions = undefined; playwright._defaultContextTimeout = undefined; playwright._defaultContextNavigationTimeout = undefined; - playwright._defaultTracesDir = undefined; }, { auto: 'all-hooks-included', title: 'context configuration', box: true } as any], _setupArtifacts: [async ({ playwright, screenshot }, use, testInfo) => {