apply
This commit is contained in:
parent
9348dd4b6e
commit
0c70096473
|
|
@ -67,6 +67,7 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
|
||||||
options = { ...this._playwright._defaultLaunchOptions, ...options };
|
options = { ...this._playwright._defaultLaunchOptions, ...options };
|
||||||
const launchOptions: channels.BrowserTypeLaunchParams = {
|
const launchOptions: channels.BrowserTypeLaunchParams = {
|
||||||
...options,
|
...options,
|
||||||
|
tracesDir: options.tracesDir ?? this._playwright._defaultTracesDir,
|
||||||
ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined,
|
ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined,
|
||||||
ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),
|
ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),
|
||||||
env: options.env ? envObjectToArray(options.env) : undefined,
|
env: options.env ? envObjectToArray(options.env) : undefined,
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ export class APIRequest implements api.APIRequest {
|
||||||
options = {
|
options = {
|
||||||
...this._playwright._defaultContextOptions,
|
...this._playwright._defaultContextOptions,
|
||||||
...options,
|
...options,
|
||||||
timeout: this._playwright._defaultActionTimeout ?? options.timeout,
|
timeout: this._playwright._defaultContextTimeout ?? options.timeout,
|
||||||
};
|
};
|
||||||
const storageState = typeof options.storageState === 'string' ?
|
const storageState = typeof options.storageState === 'string' ?
|
||||||
JSON.parse(await fs.promises.readFile(options.storageState, 'utf8')) :
|
JSON.parse(await fs.promises.readFile(options.storageState, 'utf8')) :
|
||||||
|
|
@ -74,12 +74,12 @@ export class APIRequest implements api.APIRequest {
|
||||||
...options,
|
...options,
|
||||||
extraHTTPHeaders: options.extraHTTPHeaders ? headersObjectToArray(options.extraHTTPHeaders) : undefined,
|
extraHTTPHeaders: options.extraHTTPHeaders ? headersObjectToArray(options.extraHTTPHeaders) : undefined,
|
||||||
storageState,
|
storageState,
|
||||||
tracesDir: this._playwright._tracesDir,
|
tracesDir: this._playwright._defaultTracesDir,
|
||||||
clientCertificates: await toClientCertificatesProtocol(options.clientCertificates),
|
clientCertificates: await toClientCertificatesProtocol(options.clientCertificates),
|
||||||
})).request);
|
})).request);
|
||||||
this._contexts.add(context);
|
this._contexts.add(context);
|
||||||
context._request = this;
|
context._request = this;
|
||||||
context._tracing._tracesDir = this._playwright._tracesDir;
|
context._tracing._tracesDir = this._playwright._defaultTracesDir;
|
||||||
await context._instrumentation.runAfterCreateRequestContext(context);
|
await context._instrumentation.runAfterCreateRequestContext(context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,7 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
|
||||||
_defaultContextOptions?: BrowserContextOptions;
|
_defaultContextOptions?: BrowserContextOptions;
|
||||||
_defaultContextTimeout?: number;
|
_defaultContextTimeout?: number;
|
||||||
_defaultContextNavigationTimeout?: number;
|
_defaultContextNavigationTimeout?: number;
|
||||||
_defaultActionTimeout?: number;
|
_defaultTracesDir?: string;
|
||||||
_tracesDir?: string;
|
|
||||||
|
|
||||||
constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.PlaywrightInitializer) {
|
constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.PlaywrightInitializer) {
|
||||||
super(parent, type, guid, initializer);
|
super(parent, type, guid, initializer);
|
||||||
|
|
@ -83,7 +82,7 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
|
||||||
return (channel as any)._object;
|
return (channel as any)._object;
|
||||||
}
|
}
|
||||||
|
|
||||||
_browserTypes(): BrowserType[] {
|
private _browserTypes(): BrowserType[] {
|
||||||
return [this.chromium, this.firefox, this.webkit, this._bidiChromium, this._bidiFirefox];
|
return [this.chromium, this.firefox, this.webkit, this._bidiChromium, this._bidiFirefox];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,11 +83,11 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
||||||
options.headless = headless;
|
options.headless = headless;
|
||||||
if (channel !== undefined)
|
if (channel !== undefined)
|
||||||
options.channel = channel;
|
options.channel = channel;
|
||||||
options.tracesDir = tracing().tracesDir();
|
playwright._defaultTracesDir = tracing().tracesDir();
|
||||||
|
|
||||||
playwright._defaultLaunchOptions = options;
|
playwright._defaultLaunchOptions = options;
|
||||||
await use(options);
|
await use(options);
|
||||||
playwright._defaultLaunchOptions = undefined;
|
playwright._defaultLaunchOptions = undefined;
|
||||||
|
playwright._defaultTracesDir = undefined;
|
||||||
}, { scope: 'worker', auto: true, box: true }],
|
}, { scope: 'worker', auto: true, box: true }],
|
||||||
|
|
||||||
browser: [async ({ playwright, browserName, _browserOptions, connectOptions, _reuseContext }, use, testInfo) => {
|
browser: [async ({ playwright, browserName, _browserOptions, connectOptions, _reuseContext }, use, testInfo) => {
|
||||||
|
|
@ -234,12 +234,12 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
||||||
playwright._defaultContextOptions = _combinedContextOptions;
|
playwright._defaultContextOptions = _combinedContextOptions;
|
||||||
playwright._defaultContextTimeout = actionTimeout || 0;
|
playwright._defaultContextTimeout = actionTimeout || 0;
|
||||||
playwright._defaultContextNavigationTimeout = navigationTimeout || 0;
|
playwright._defaultContextNavigationTimeout = navigationTimeout || 0;
|
||||||
playwright._tracesDir = tracing().tracesDir();
|
playwright._defaultTracesDir = tracing().tracesDir();
|
||||||
await use();
|
await use();
|
||||||
playwright._defaultContextOptions = undefined;
|
playwright._defaultContextOptions = undefined;
|
||||||
playwright._defaultContextTimeout = undefined;
|
playwright._defaultContextTimeout = undefined;
|
||||||
playwright._defaultContextNavigationTimeout = undefined;
|
playwright._defaultContextNavigationTimeout = undefined;
|
||||||
playwright._tracesDir = undefined;
|
playwright._defaultTracesDir = undefined;
|
||||||
}, { auto: 'all-hooks-included', title: 'context configuration', box: true } as any],
|
}, { auto: 'all-hooks-included', title: 'context configuration', box: true } as any],
|
||||||
|
|
||||||
_setupArtifacts: [async ({ playwright, screenshot }, use, testInfo) => {
|
_setupArtifacts: [async ({ playwright, screenshot }, use, testInfo) => {
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ export class RemoteServer implements PlaywrightServer {
|
||||||
|
|
||||||
async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, channel: string, remoteServerOptions: RemoteServerOptions = {}) {
|
async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, channel: string, remoteServerOptions: RemoteServerOptions = {}) {
|
||||||
this._browserType = browserType;
|
this._browserType = browserType;
|
||||||
const browserOptions = (browserType as any).plawright._defaultLaunchOptions;
|
const browserOptions = (browserType as any)._plawright._defaultLaunchOptions;
|
||||||
// Copy options to prevent a large JSON string when launching subprocess.
|
// Copy options to prevent a large JSON string when launching subprocess.
|
||||||
// Otherwise, we get `Error: spawn ENAMETOOLONG` on Windows.
|
// Otherwise, we get `Error: spawn ENAMETOOLONG` on Windows.
|
||||||
const launchOptions: Parameters<BrowserType['launchServer']>[0] = {
|
const launchOptions: Parameters<BrowserType['launchServer']>[0] = {
|
||||||
|
|
|
||||||
|
|
@ -630,14 +630,14 @@ for (const kind of ['launchServer', 'run-server'] as const) {
|
||||||
|
|
||||||
test('should filter launch options', async ({ connect, startRemoteServer, server, browserType }, testInfo) => {
|
test('should filter launch options', async ({ connect, startRemoteServer, server, browserType }, testInfo) => {
|
||||||
const tracesDir = testInfo.outputPath('traces');
|
const tracesDir = testInfo.outputPath('traces');
|
||||||
const oldTracesDir = (browserType as any)._playwright._defaultLaunchOptions.tracesDir;
|
const oldTracesDir = (browserType as any)._playwright._defaultTracesDir;
|
||||||
(browserType as any)._playwright._defaultLaunchOptions.tracesDir = tracesDir;
|
(browserType as any)._playwright._defaultTracesDir = tracesDir;
|
||||||
const remoteServer = await startRemoteServer(kind);
|
const remoteServer = await startRemoteServer(kind);
|
||||||
const browser = await connect(remoteServer.wsEndpoint());
|
const browser = await connect(remoteServer.wsEndpoint());
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
await browser.close();
|
await browser.close();
|
||||||
(browserType as any)._playwright._defaultLaunchOptions.tracesDir = oldTracesDir;
|
(browserType as any)._playwright._defaultTracesDir = oldTracesDir;
|
||||||
expect(fs.existsSync(tracesDir)).toBe(false);
|
expect(fs.existsSync(tracesDir)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -368,8 +368,8 @@ test('should not crash when browser closes mid-trace', async ({ browserType, ser
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should survive browser.close with auto-created traces dir', async ({ browserType }, testInfo) => {
|
test('should survive browser.close with auto-created traces dir', async ({ browserType }, testInfo) => {
|
||||||
const oldTracesDir = (browserType as any)._playwright._defaultLaunchOptions.tracesDir;
|
const oldTracesDir = (browserType as any)._playwright._defaultTracesDir;
|
||||||
(browserType as any)._playwright._defaultLaunchOptions.tracesDir = undefined;
|
(browserType as any)._playwright._defaultTracesDir = undefined;
|
||||||
const browser = await browserType.launch();
|
const browser = await browserType.launch();
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.context().tracing.start();
|
await page.context().tracing.start();
|
||||||
|
|
@ -394,7 +394,7 @@ test('should survive browser.close with auto-created traces dir', async ({ brows
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done.value = true;
|
done.value = true;
|
||||||
(browserType as any)._playwright._defaultLaunchOptions.tracesDir = oldTracesDir;
|
(browserType as any)._playwright._defaultTracesDir = oldTracesDir;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not stall on dialogs', async ({ page, context, server }) => {
|
test('should not stall on dialogs', async ({ page, context, server }) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue