Skip to content

Commit

Permalink
fix: typings
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Dec 19, 2023
1 parent deaa7d6 commit feba91a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/browser/commands/scrollIntoView.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
type Browser = {
publicAPI: WebdriverIO.Browser;
};
import type { Browser } from "../types";

// TODO: remove after fix https://github.com/webdriverio/webdriverio/issues/9620
export = async (browser: Browser): Promise<void> => {
Expand Down
20 changes: 20 additions & 0 deletions src/browser/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import type { AssertViewCommand, AssertViewElementCommand } from "./commands/types";
import type { BrowserConfig } from "./../config/browser-config";
import type { AssertViewResult, RunnerTest, RunnerHook } from "../types";

export interface BrowserMeta {
pid: number;
browserVersion: string;
[name: string]: unknown;
}

export interface Browser {
publicAPI: WebdriverIO.Browser;
config: BrowserConfig;
state: Record<string, unknown>;
applyState: (state: Record<string, unknown>) => void;
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace WebdriverIO {
Expand Down Expand Up @@ -70,6 +79,17 @@ declare global {
* @returns {Promise<any>} value, returned by `stepCb`
*/
runStep(stepName: string, stepCb: () => Promise<unknown> | unknown): Promise<unknown>;

// TODO: describe executionContext more precisely
executionContext: (RunnerTest | RunnerHook) & {
hermioneCtx: {
assertViewResults: Array<AssertViewResult>;
};
ctx: {
browser: WebdriverIO.Browser;
currentTest: RunnerTest;
};
};
}

interface Element {
Expand Down
8 changes: 8 additions & 0 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ export interface CommonConfig {
system: SystemConfig;
headless: boolean | null;
isolation: boolean;

openAndWaitOpts: {
timeout?: number;
waitNetworkIdle: boolean;
waitNetworkIdleTimeout: number;
failOnNetworkError: boolean;
ignoreNetworkErrorsPatterns: Array<RegExp | string>;
};
}

export interface SetsConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { WorkerProcess } from "../utils/worker-process";
import { BaseHermione } from "../base-hermione";
import { CoordBounds, LooksSameOptions } from "looks-same";

export { Suite as RunnerSuite, Test as RunnerTest } from "mocha";
export { Suite as RunnerSuite, Test as RunnerTest, Hook as RunnerHook } from "mocha";

export type { Browser as WdioBrowser } from "webdriverio";

Expand Down
4 changes: 3 additions & 1 deletion src/utils/worker-process.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ChildProcess } from "child_process";

type Serializable = string | object | number | boolean | bigint;

export class WorkerProcess {
protected process: ChildProcess;

Expand All @@ -11,7 +13,7 @@ export class WorkerProcess {
this.process = process;
}

send(message: unknown): boolean {
send(message: Serializable): boolean {
if (!this.process.connected) {
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ interface SuiteDefinition {
only: (title: string, fn: (this: Mocha.Suite) => void) => Mocha.Suite;
skip: (title: string, fn: (this: Mocha.Suite) => void) => Mocha.Suite;
}

declare namespace globalThis {
// eslint-disable-next-line no-var
var expect: ExpectWebdriverIO.Expect;
}

0 comments on commit feba91a

Please sign in to comment.