* 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.
20 lines
706 B
TypeScript
20 lines
706 B
TypeScript
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[]>;
|
|
}
|
|
} |