fix(fixtures): account for default options being undefined (#11916)
This commit is contained in:
parent
1e00218ead
commit
7912c515a3
|
|
@ -47,8 +47,8 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
|
||||||
_playwright!: Playwright;
|
_playwright!: Playwright;
|
||||||
|
|
||||||
// Instrumentation.
|
// Instrumentation.
|
||||||
_defaultContextOptions: BrowserContextOptions = {};
|
_defaultContextOptions?: BrowserContextOptions;
|
||||||
_defaultLaunchOptions: LaunchOptions = {};
|
_defaultLaunchOptions?: LaunchOptions;
|
||||||
_onDidCreateContext?: (context: BrowserContext) => Promise<void>;
|
_onDidCreateContext?: (context: BrowserContext) => Promise<void>;
|
||||||
_onWillCloseContext?: (context: BrowserContext) => Promise<void>;
|
_onWillCloseContext?: (context: BrowserContext) => Promise<void>;
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
|
||||||
}
|
}
|
||||||
|
|
||||||
async launch(options: LaunchOptions = {}): Promise<Browser> {
|
async launch(options: LaunchOptions = {}): Promise<Browser> {
|
||||||
const logger = options.logger || this._defaultLaunchOptions.logger;
|
const logger = options.logger || this._defaultLaunchOptions?.logger;
|
||||||
assert(!(options as any).userDataDir, 'userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistentContext` instead');
|
assert(!(options as any).userDataDir, 'userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistentContext` instead');
|
||||||
assert(!(options as any).port, 'Cannot specify a port without launching as a server.');
|
assert(!(options as any).port, 'Cannot specify a port without launching as a server.');
|
||||||
options = { ...this._defaultLaunchOptions, ...options };
|
options = { ...this._defaultLaunchOptions, ...options };
|
||||||
|
|
@ -92,7 +92,7 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
|
||||||
}
|
}
|
||||||
|
|
||||||
async launchPersistentContext(userDataDir: string, options: LaunchPersistentContextOptions = {}): Promise<BrowserContext> {
|
async launchPersistentContext(userDataDir: string, options: LaunchPersistentContextOptions = {}): Promise<BrowserContext> {
|
||||||
const logger = options.logger || this._defaultLaunchOptions.logger;
|
const logger = options.logger || this._defaultLaunchOptions?.logger;
|
||||||
assert(!(options as any).port, 'Cannot specify a port without launching as a server.');
|
assert(!(options as any).port, 'Cannot specify a port without launching as a server.');
|
||||||
options = { ...this._defaultLaunchOptions, ...this._defaultContextOptions, ...options };
|
options = { ...this._defaultLaunchOptions, ...this._defaultContextOptions, ...options };
|
||||||
const contextParams = await prepareBrowserContextParams(options);
|
const contextParams = await prepareBrowserContextParams(options);
|
||||||
|
|
|
||||||
|
|
@ -457,11 +457,12 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
||||||
|
|
||||||
|
|
||||||
function formatPendingCalls(calls: ParsedStackTrace[]) {
|
function formatPendingCalls(calls: ParsedStackTrace[]) {
|
||||||
|
calls = calls.filter(call => !!call.apiName);
|
||||||
if (!calls.length)
|
if (!calls.length)
|
||||||
return '';
|
return '';
|
||||||
return 'Pending operations:\n' + calls.map(call => {
|
return 'Pending operations:\n' + calls.map(call => {
|
||||||
const frame = call.frames && call.frames[0] ? formatStackFrame(call.frames[0]) : '<unknown>';
|
const frame = call.frames && call.frames[0] ? ' at ' + formatStackFrame(call.frames[0]) : '';
|
||||||
return ` - ${call.apiName} at ${frame}\n`;
|
return ` - ${call.apiName}${frame}\n`;
|
||||||
}).join('') + '\n';
|
}).join('') + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue