Add Browserstack API integration and supported browser type

* Created `BrowserstackApi` class for interacting with the Browserstack API, including a method to fetch supported browsers.
* Introduced `SupportedBrowser` type to define the structure of browser data returned from the API.
* Updated `TestRunner` to instantiate and run the test execution process, enabling command line options logging.
This commit is contained in:
2025-08-18 18:05:29 -04:00
parent 4b672f231f
commit 9e063550c2
3 changed files with 34 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
import SupportedBrowser from "./SupportedBrowser";
export class BrowserstackApi {
private readonly _baseUrl: string = 'https://api.browserstack.com/5';
private readonly _authorizationHeader: string;
constructor(username: string, accessKey: string) {
this._authorizationHeader = `Basic ${Buffer.from(`${username}:${accessKey}`).toString('base64')}`;
}
public async getSupportedBrowsers(): Promise<SupportedBrowser[]> {
const response = await fetch(`${this._baseUrl}/browsers?flat=true`, {
headers: {
'Authorization': this._authorizationHeader
}
});
return response.json() as Promise<SupportedBrowser[]>;
}
}

View File

@@ -0,0 +1,10 @@
type SupportedBrowser = {
os: string;
os_version: string;
browser: string;
device: string;
browser_version: string | null;
real_mobile: boolean;
}
export default SupportedBrowser

View File

@@ -12,9 +12,11 @@ class TestRunner {
private static readonly _commandLineOptions: CommandLineOptions = CommandLine.parse(process.argv);
public static main(): void {
// const testRunner = new TestRunner();
// testRunner.run();
const testRunner = new TestRunner();
testRunner.run();
}
public run(): void {
console.log(TestRunner._commandLineOptions);
}
}