Skip to content

Commit

Permalink
fix: add typings for overwrireCommand: custom commands
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovRoman committed Mar 12, 2024
1 parent b6b4836 commit fc028a0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/browser/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export interface Browser {
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace WebdriverIO {
type OverwriteCommandFn<IsElement extends boolean = false> = (
this: IsElement extends true ? WebdriverIO.Element : WebdriverIO.Browser,
origCommand: (...args: any[]) => Promise<any>, // eslint-disable-line @typescript-eslint/no-explicit-any
...args: any[] // eslint-disable-line @typescript-eslint/no-explicit-any
) => Promise<any>; // eslint-disable-line @typescript-eslint/no-explicit-any

interface Browser {
getMeta(): Promise<BrowserMeta>;
getMeta(key: string): Promise<unknown>;
Expand All @@ -28,6 +34,14 @@ declare global {

getConfig(): Promise<BrowserConfig>;

overwriteCommand<IsElement extends boolean = false>(
name: string,
func: OverwriteCommandFn<IsElement>,
attachToElement?: IsElement,
proto?: Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any
instances?: Record<string, WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser>,
): void;

/**
* Takes a screenshot of the passed selector and compares the received screenshot with the reference.
*
Expand Down

0 comments on commit fc028a0

Please sign in to comment.