Enhance CommandLine and TestConfiguration for improved option validation and logging
* Added validation for required command line options in the `CommandLine` class to ensure necessary parameters are provided. * Updated `TestConfiguration` to store and expose the logging level from command line options. * Refactored `BrowserstackApi` to improve method naming and added content type headers for API requests. * Changed `SupportedBrowser` type to be exported for better accessibility. * Updated `Page` and `SubscribingPage` classes to use a consistent browser import and improved constructor parameters.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import SupportedBrowser from './SupportedBrowser';
|
||||
import type {SupportedBrowser} from './SupportedBrowser';
|
||||
|
||||
// Source: https://github.com/browserstack/api
|
||||
|
||||
@@ -10,16 +10,18 @@ export class BrowserstackApi {
|
||||
this._authorizationHeader = `Basic ${Buffer.from(`${username}:${accessKey}`).toString('base64')}`;
|
||||
}
|
||||
|
||||
public async getSupportedBrowsers(): Promise<SupportedBrowser[]> {
|
||||
const endpoint = `${this._baseUrl}/browsers?flat=true`;
|
||||
public async getListOfSupportedBrowsers(): Promise<SupportedBrowser[]> {
|
||||
const requestPath = `${this._baseUrl}/browsers?flat=true`;
|
||||
const headers = {
|
||||
Authorization: this._authorizationHeader
|
||||
Authorization: this._authorizationHeader,
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json'
|
||||
};
|
||||
|
||||
const response = await fetch(endpoint, {headers});
|
||||
const response = await fetch(requestPath, {headers});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch BrowserStack supported browsers due to [ ${response.statusText}]`);
|
||||
throw new Error(`Failed to fetch BrowserStack supported browsers due to [${response.statusText}]`);
|
||||
}
|
||||
|
||||
return response.json() as Promise<SupportedBrowser[]>;
|
||||
|
||||
Reference in New Issue
Block a user