@wdio/devtools-service
Version:
A WebdriverIO service that allows you to run Chrome DevTools commands in your tests
57 lines • 2.82 kB
TypeScript
import type { Capabilities, Services, FunctionProperties, ThenArg } from '@wdio/types';
import CommandHandler from './commands.js';
import type Auditor from './auditor.js';
import type { DevtoolsConfig, EnablePerformanceAuditsOptions, DeviceDescription, PWAAudits, DeviceOptions } from './types.js';
export default class DevToolsService implements Services.ServiceInstance {
private _options;
private _command;
private _browser?;
constructor(_options: DevtoolsConfig);
before(caps: Capabilities.RemoteCapability, specs: string[], browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): Promise<void>;
onReload(): Promise<void>;
beforeCommand(commandName: string, params: any[]): Promise<(void | undefined)[]>;
afterCommand(commandName: string): Promise<(void | undefined)[]>;
after(): Promise<void>;
/**
* set flag to run performance audits for page transitions
*/
_enablePerformanceAudits({ networkThrottling, cpuThrottling, cacheEnabled, formFactor }?: EnablePerformanceAuditsOptions): void;
/**
* custom command to disable performance audits
*/
_disablePerformanceAudits(): void;
/**
* set device emulation
*/
_emulateDevice(device: string | DeviceDescription, deviceOptions?: DeviceOptions): Promise<void | void[]>;
_setThrottlingProfile(networkThrottling?: "online" | "offline" | "GPRS" | "Regular 2G" | "Good 2G" | "Regular 3G" | "Good 3G" | "Regular 4G" | "DSL" | "Wifi", cpuThrottling?: number, cacheEnabled?: boolean): Promise<void>;
_checkPWA(auditsToBeRun?: PWAAudits[]): Promise<import("./types.js").AuditResult | import("./types.js").AuditResult[]>;
_getCoverageReport(): Promise<import("./types.js").Coverage | (import("./types.js").Coverage | null)[] | null>;
_cdp(domain: string, command: string, args?: {}): Promise<any>;
_setupHandler(): Promise<void>;
}
export * from './types.js';
type CommandHandlerCommands = FunctionProperties<CommandHandler>;
type AuditorCommands = Omit<FunctionProperties<Auditor>, '_audit' | '_auditPWA' | 'updateCommands'>;
/**
* ToDo(Christian): use key remapping with TS 4.1
* https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#key-remapping-in-mapped-types
*/
interface BrowserExtension extends CommandHandlerCommands, AuditorCommands {
}
export type BrowserExtensionSync = {
[K in keyof BrowserExtension]: (...args: Parameters<BrowserExtension[K]>) => ThenArg<ReturnType<BrowserExtension[K]>>;
};
declare global {
namespace WebdriverIO {
interface ServiceOption extends DevtoolsConfig {
}
}
namespace WebdriverIO {
interface Browser extends BrowserExtension {
}
interface MultiRemoteBrowser extends BrowserExtension {
}
}
}
//# sourceMappingURL=index.d.ts.map