Skip to content

Commit

Permalink
Remove browserstack as a dependency (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekevinscott authored Oct 9, 2023
1 parent 5ca0810 commit d45a07d
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 228 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'path';
import browserstack from 'browserstack-local';
import webdriver, { WebDriver, ThenableWebDriver, Builder, logging } from 'selenium-webdriver';
import * as dotenv from 'dotenv';
import { ROOT_DIR } from './constants';
Expand All @@ -8,8 +7,6 @@ import { existsSync, readFileSync, writeFileSync } from 'fs-extra';
/****
* Types
*/
export type Browserstack = browserstack.Local;

export interface BrowserOption {
os?: string;
os_version: string;
Expand Down Expand Up @@ -84,49 +81,6 @@ function shouldPrintLogs (entry: logging.Entry, capabilities: BrowserOption) {
*/
export const getBrowserstackAccessKey = () => getEnv().BROWSERSTACK_ACCESS_KEY;

export const startBrowserstack = ({
key,
bs,
verbose = true,
}: {
key?: string;
bs?: browserstack.Local;
verbose?: boolean;
}): Promise<Browserstack> => new Promise((resolve, reject) => {
if (!key) {
throw new Error('A key must be passed to start up the local browserstack service');
}
if (!bs) {
if (verbose) {
console.log('Start browserstack with a brand new object')
}
bs = new browserstack.Local();
} else {
if (verbose) {
console.log('Start browserstack with an existing object')
}
}
bs.start({
key,
force: true,
onlyAutomate: true,
forceLocal: true,
}, (error) => {
if (error) {
return reject(error);
}
if (bs?.isRunning() !== true) {
throw new Error('Browserstack failed to start');
}
if (verbose) {
console.log('Browserstack started');
}
return resolve(bs);
});
});

export const stopBrowserstack = (bs: Browserstack): Promise<void> => new Promise(resolve => bs.stop(() => resolve()));

export const getBrowserOptions = (filter?: FilterBrowserOption): Array<BrowserOption> => browserOptions.filter(filter || Boolean);

export const getMobileBrowserOptions = (filter?: FilterBrowserOption): Array<BrowserOption> => mobileBrowserOptions.filter(filter || Boolean);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
"babel-plugin-add-module-exports": "1.0.4",
"browserstack-local": "1.5.4",
"chai": "4.3.7",
"chai-as-promised": "7.1.1",
"chokidar": "3.5.3",
Expand Down
79 changes: 0 additions & 79 deletions pnpm-lock.yaml

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

46 changes: 0 additions & 46 deletions scripts/package-scripts/utils/browserStack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'path';
import browserstack from 'browserstack-local';
import webdriver, { WebDriver, ThenableWebDriver, Builder, logging } from 'selenium-webdriver';
import * as dotenv from 'dotenv';
import { ROOT_DIR } from './constants';
Expand All @@ -8,8 +7,6 @@ import { existsSync, readFileSync, writeFileSync } from 'fs-extra';
/****
* Types
*/
export type Browserstack = browserstack.Local;

export interface BrowserOption {
os?: string;
os_version: string;
Expand Down Expand Up @@ -88,49 +85,6 @@ function shouldPrintLogs (entry: logging.Entry, capabilities: BrowserOption) {
*/
export const getBrowserstackAccessKey = () => getEnv().BROWSERSTACK_ACCESS_KEY;

export const startBrowserstack = async ({
key,
bs,
verbose = true,
}: {
key?: string;
bs?: browserstack.Local;
verbose?: boolean;
}): Promise<Browserstack> => new Promise((resolve, reject) => {
if (!key) {
throw new Error('A key must be passed to start up the local browserstack service');
}
if (!bs) {
if (verbose) {
console.log('Start browserstack with a brand new object')
}
bs = new browserstack.Local();
} else {
if (verbose) {
console.log('Start browserstack with an existing object')
}
}
bs.start({
key,
force: true,
onlyAutomate: true,
forceLocal: true,
}, (error) => {
if (error) {
return reject(error);
}
if (bs?.isRunning() !== true) {
throw new Error('Browserstack failed to start');
}
if (verbose) {
console.log('Browserstack started');
}
resolve(bs);
});
});

export const stopBrowserstack = (bs: Browserstack): Promise<void> => new Promise(resolve => bs.stop(() => resolve()));

export const getBrowserOptions = (filter?: FilterBrowserOption): Array<BrowserOption> => browserOptions.filter(filter || Boolean);

export const getMobileBrowserOptions = (filter?: FilterBrowserOption): Array<BrowserOption> => mobileBrowserOptions.filter(filter || Boolean);
Expand Down
Loading

0 comments on commit d45a07d

Please sign in to comment.