This commit is contained in:
Simon Knott 2025-02-06 16:40:46 +01:00
parent f90e1c575d
commit c7b95f1dbd
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
4 changed files with 4 additions and 8 deletions

View file

@ -67,7 +67,6 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> 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,

View file

@ -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;
}

View file

@ -42,7 +42,6 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
_defaultContextOptions?: BrowserContextOptions;
_defaultContextTimeout?: number;
_defaultContextNavigationTimeout?: number;
_defaultTracesDir?: string;
constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.PlaywrightInitializer) {
super(parent, type, guid, initializer);

View file

@ -83,11 +83,11 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
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<TestFixtures, WorkerFixtures> = ({
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) => {