Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: re-write existing-browser to typescript #1061

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"@types/sharp": "0.31.1",
"@types/sinon": "17.0.1",
"@types/sinonjs__fake-timers": "8.1.2",
"@types/strftime": "0.9.8",
"@types/urijs": "1.19.25",
"@types/url-join": "4.0.3",
"@types/yallist": "4.0.4",
Expand All @@ -151,8 +152,8 @@
"eslint": "8.25.0",
"eslint-config-gemini-testing": "2.8.0",
"eslint-config-prettier": "8.7.0",
"glob-extra": "5.0.2",
"execa": "5.1.1",
"glob-extra": "5.0.2",
"husky": "0.11.4",
"js-levenshtein": "1.1.6",
"jsdom": "^24.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/browser-installer/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type DownloadProgressCallback,
} from "../utils";
import { getFirefoxBuildId } from "../firefox/utils";
import logger from "../../utils/logger";
import * as logger from "../../utils/logger";
import { BrowserName } from "../../browser/types";

type VersionToPathMap = Record<string, string | Promise<string>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Cache } from "./cache";
import { fetchBrowsersMilestones } from "./browser-versions/index";
import { downloadBrowserVersions } from "./browser-downloader";
import { getUbuntuMilestone, writeUbuntuPackageDependencies } from "..";
import logger from "../../../utils/logger";
import * as logger from "../../../utils/logger";

const createResolveSharedObjectToPackageName =
(cache: Cache) =>
Expand Down
2 changes: 1 addition & 1 deletion src/browser-installer/ubuntu-packages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "path";
import { getOsPackagesDir, type DownloadProgressCallback, browserInstallerDebug } from "../utils";
import { installUbuntuPackages } from "./apt";
import { getUbuntuMilestone } from "./utils";
import logger from "../../utils/logger";
import * as logger from "../../utils/logger";
import { LINUX_RUNTIME_LIBRARIES_PATH_ENV_NAME, LINUX_UBUNTU_RELEASE_ID } from "../constants";
import registry from "../registry";

Expand Down
2 changes: 1 addition & 1 deletion src/browser-pool/basic-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class BasicPool implements Pool {
}

async getBrowser(id: string, opts: BrowserOpts = {}): Promise<NewBrowser> {
const browser = NewBrowser.create(this._config, { ...opts, id, wdPool: this._wdPool });
const browser = NewBrowser.create(this._config, { ...opts, id, wdPool: this._wdPool, emitter: this._emitter });

try {
await browser.init();
Expand Down
14 changes: 10 additions & 4 deletions src/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import _ from "lodash";

import { SAVE_HISTORY_MODE } from "../constants/config";
import { X_REQUEST_ID_DELIMITER } from "../constants/browser";
import history from "./history";
import * as history from "./history";
import { enhanceStacktraces } from "./stacktrace";
import { getBrowserCommands, getElementCommands } from "./history/commands";
import addRunStepCommand from "./commands/runStep";
import { Config } from "../config";
import { AsyncEmitter } from "../events";
import { BrowserConfig } from "../config/browser-config";
import Callstack from "./history/callstack";
import type { Callstack } from "./history/callstack";
import type { WdProcess, WebdriverPool } from "../browser-pool/webdriver-pool";

import type { Capabilities } from "@wdio/types";
Expand All @@ -33,7 +33,7 @@ export type BrowserOpts = {
id: string;
version?: string;
state?: Record<string, unknown>;
emitter?: AsyncEmitter;
emitter: AsyncEmitter;
wdPool?: WebdriverPool;
};

Expand All @@ -46,6 +46,7 @@ export type BrowserState = {
export type CustomCommend = { name: string; elementScope: boolean };

export class Browser {
protected _emitter: AsyncEmitter;
protected _config: BrowserConfig;
protected _debug: boolean;
protected _session: WebdriverIO.Browser | null;
Expand Down Expand Up @@ -80,6 +81,7 @@ export class Browser {
};
this._customCommands = new Set();
this._wdPool = opts.wdPool;
this._emitter = opts.emitter;
}

setHttpTimeout(timeout: number | null): void {
Expand Down Expand Up @@ -112,7 +114,7 @@ export class Browser {

protected _addHistory(): void {
if (this._config.saveHistoryMode !== SAVE_HISTORY_MODE.NONE) {
this._callstackHistory = history.initCommandHistory(this._session);
this._callstackHistory = history.initCommandHistory(this._session as WebdriverIO.Browser);
}
}

Expand Down Expand Up @@ -196,4 +198,8 @@ export class Browser {
const allCustomCommands = Array.from(this._customCommands);
return _.uniqWith(allCustomCommands, _.isEqual);
}

get emitter(): AsyncEmitter {
return this._emitter;
}
}
134 changes: 0 additions & 134 deletions src/browser/calibrator.js

This file was deleted.

Loading