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:
20
test/config/Browserstack/BrowserstackApi.ts
Normal file
20
test/config/Browserstack/BrowserstackApi.ts
Normal 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[]>;
|
||||
}
|
||||
}
|
||||
10
test/config/Browserstack/SupportedBrowser.ts
Normal file
10
test/config/Browserstack/SupportedBrowser.ts
Normal 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
|
||||
Reference in New Issue
Block a user