UNPKG

@wdio/browserstack-service

Version:
194 lines 11.2 kB
import type { Capabilities, Frameworks, Options } from '@wdio/types'; import type { BeforeCommandArgs, AfterCommandArgs } from '@wdio/reporter'; import type { ColorName } from 'chalk'; import type { UploadType, BrowserstackConfig, BrowserstackOptions, LaunchResponse } from './types.js'; import type { ITestCaseHookParameter } from './cucumber-types.js'; export type GitMetaData = { name: string; sha: string; short_sha: string; branch: string; tag: string | null; committer: string; committer_date: string; author: string; author_date: string; commit_message: string; root: string; common_git_dir: string; worktree_git_dir: string; last_tag: string | null; commits_since_last_tag: number; remotes: Array<{ name: string; url: string; }>; }; export declare const DEFAULT_REQUEST_CONFIG: { headers: { 'Content-Type': string; 'X-BSTACK-OBS': string; }; }; export declare const COLORS: Record<string, ColorName>; /** * get browser description for Browserstack service * @param cap browser capablities */ export declare function getBrowserDescription(cap: WebdriverIO.Capabilities): string; /** * get correct browser capabilities object in both multiremote and normal setups * @param browser browser object * @param caps browser capbilities object. In case of multiremote, the object itself should have a property named 'capabilities' * @param browserName browser name in case of multiremote */ export declare function getBrowserCapabilities(browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, caps?: Capabilities.ResolvedTestrunnerCapabilities, browserName?: string): WebdriverIO.Capabilities; /** * check for browserstack W3C capabilities. Does not support legacy capabilities * @param cap browser capabilities */ export declare function isBrowserstackCapability(cap?: WebdriverIO.Capabilities): boolean; export declare function getParentSuiteName(fullTitle: string, testSuiteTitle: string): string; export declare function o11yErrorHandler(fn: Function): (...args: unknown[]) => any; export declare function errorHandler(fn: Function): (...args: unknown[]) => any; export declare function nodeRequest(requestType: string, apiEndpoint: string, options: RequestInit, apiUrl: string, timeout?: number): Promise<any>; type ClassType = { new (...args: unknown[]): unknown; }; export declare function o11yClassErrorHandler<T extends ClassType>(errorClass: T): T; export declare const processTestObservabilityResponse: (response: LaunchResponse) => void; interface DataElement { [key: string]: unknown; } export declare const jsonifyAccessibilityArray: (dataArray: DataElement[], keyName: keyof DataElement, valueName: keyof DataElement) => Record<string, unknown>; export declare const processAccessibilityResponse: (response: LaunchResponse, options: BrowserstackConfig & Options.Testrunner) => void; export declare const processLaunchBuildResponse: (response: LaunchResponse, options: BrowserstackConfig & Options.Testrunner) => void; export declare const launchTestSession: (...args: (object | boolean | undefined | null | string)[]) => any; export declare const validateCapsWithAppA11y: (platformMeta?: { [key: string]: any; }) => boolean; export declare const validateCapsWithA11y: (deviceName?: any, platformMeta?: { [key: string]: any; }, chromeOptions?: any) => boolean; export declare const validateCapsWithNonBstackA11y: (browserName?: string | undefined, browserVersion?: string | undefined) => boolean; export declare const shouldScanTestForAccessibility: (suiteTitle: string | undefined, testTitle: string, accessibilityOptions?: { [key: string]: string; }, world?: { [key: string]: unknown; }, isCucumber?: boolean) => boolean; export declare const isAccessibilityAutomationSession: (accessibilityFlag?: boolean | string | null) => boolean | "" | null | undefined; export declare const isAppAccessibilityAutomationSession: (accessibilityFlag?: boolean | string, isAppAutomate?: boolean) => boolean | "" | null | undefined; export declare const formatString: (template: (string | null), ...values: (string | null)[]) => string; export declare const _getParamsForAppAccessibility: (commandName?: string) => { thTestRunUuid: any; thBuildUuid: any; thJwtToken: any; authHeader: any; scanTimestamp: number; method: string | undefined; }; export declare const performA11yScan: (isAppAutomate: boolean, browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, isBrowserStackSession?: boolean, isAccessibility?: boolean | string, commandName?: string) => Promise<{ [key: string]: any; } | undefined>; export declare const getA11yResults: (...args: (object | boolean | undefined | null | string)[]) => any; export declare const getAppA11yResults: (...args: (object | boolean | undefined | null | string)[]) => any; export declare const getAppA11yResultsSummary: (...args: (object | boolean | undefined | null | string)[]) => any; export declare const getA11yResultsSummary: (...args: (object | boolean | undefined | null | string)[]) => any; export declare const stopBuildUpstream: (...args: (object | boolean | undefined | null | string)[]) => any; export declare function getCiInfo(): { name: string; build_url: string | undefined; job_name: string | undefined; build_number: string | undefined; } | { name: string; build_url: string | undefined; job_name: string | null; build_number: string | undefined; } | { name: string; build_url: null; job_name: string | undefined; build_number: string | undefined; } | { name: string; build_url: string; job_name: null; build_number: null; } | { name: string; build_url: null; job_name: null; build_number: string | undefined; } | { name: string; build_url: null; job_name: string | null; build_number: string | null; } | null; export declare function getGitMetaData(): Promise<GitMetaData | undefined>; export declare function getUniqueIdentifier(test: Frameworks.Test, framework?: string): string; export declare function getUniqueIdentifierForCucumber(world: ITestCaseHookParameter): string; export declare function getCloudProvider(browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): string; export declare function isBrowserstackSession(browser?: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): boolean | undefined; export declare function getScenarioExamples(world: ITestCaseHookParameter): string[] | undefined; export declare function removeAnsiColors(message: string): string; export declare function getLogTag(eventType: string): string; export declare function getHierarchy(fullTitle?: string): string[]; export declare function getHookType(hookName: string): string; export declare function isScreenshotCommand(args: BeforeCommandArgs | AfterCommandArgs): boolean | "" | undefined; export declare function isBStackSession(config: Options.Testrunner): boolean; export declare function isBrowserstackInfra(config: BrowserstackConfig & Options.Testrunner, caps?: Capabilities.BrowserStackCapabilities): boolean; export declare function getBrowserStackUserAndKey(config: Options.Testrunner, options: Options.Testrunner): { user: string | undefined; key: string | undefined; }; export declare function shouldAddServiceVersion(config: Options.Testrunner, testObservability?: boolean, caps?: Capabilities.BrowserStackCapabilities): boolean; export declare function batchAndPostEvents(eventUrl: string, kind: string, data: UploadType[]): Promise<void>; export declare function getObservabilityUser(options: BrowserstackConfig & Options.Testrunner, config: Options.Testrunner): string | undefined; export declare function getObservabilityKey(options: BrowserstackConfig & Options.Testrunner, config: Options.Testrunner): string | undefined; export declare function getObservabilityProject(options: BrowserstackConfig & Options.Testrunner, bstackProjectName?: string): string | undefined; export declare function getObservabilityBuild(options: BrowserstackConfig & Options.Testrunner, bstackBuildName?: string): string; export declare function getObservabilityBuildTags(options: BrowserstackConfig & Options.Testrunner, bstackBuildTag?: string): string[]; export declare function getBrowserStackUser(config: Options.Testrunner): string; export declare function getBrowserStackKey(config: Options.Testrunner): string | undefined; export declare function isUndefined(value: unknown): boolean; export declare function isTrue(value?: unknown): boolean; export declare function isFalse(value?: unknown): boolean; export declare function frameworkSupportsHook(hook: string, framework?: string): boolean; export declare const patchConsoleLogs: (...args: unknown[]) => any; export declare function getFailureObject(error: string | Error): { failure: { backtrace: string[]; }[]; failure_reason: string; failure_type: string | null; }; export declare const sleep: (ms?: number) => Promise<unknown>; export declare function uploadLogs(user: string | undefined, key: string | undefined, clientBuildUuid: string): Promise<any>; export declare const isObject: (object: unknown) => boolean; export declare const ObjectsAreEqual: (object1: object, object2: object) => boolean; export declare const getPlatformVersion: (...args: unknown[]) => any; export declare const getBasicAuthHeader: (username: string, password: string) => string; export declare const isObjectEmpty: (objectName: unknown) => unknown; export declare const getErrorString: (err: unknown) => string | undefined; export declare function truncateString(field: string, truncateSizeInBytes: number): string; export declare function getSizeOfJsonObjectInBytes(jsonData: GitMetaData): number; export declare function checkAndTruncateVCSInfo(gitMetaData: GitMetaData): GitMetaData; export declare const hasBrowserName: (cap: Capabilities.WebdriverIOConfig) => boolean; export declare const isValidCapsForHealing: (caps: WebdriverIO.Capabilities) => boolean; export declare function isTurboScale(options: (BrowserstackConfig & BrowserstackOptions) | undefined): boolean; export declare function getObservabilityProduct(options: (BrowserstackConfig & BrowserstackOptions) | undefined, isAppAutomate: boolean | undefined): string; type PollingResult = { data: any; headers: Record<string, any>; message?: string; }; export declare function pollApi(url: string, params: Record<string, any>, headers: Record<string, string>, upperLimit: number, startTime?: number): Promise<PollingResult>; export declare function executeAccessibilityScript<ReturnType>(browser: any, fnBody: string, arg?: unknown): Promise<ReturnType>; export declare function generateHashCodeFromFields(fields: Array<string | object>): string; export declare function getBooleanValueFromString(value: string | undefined): boolean; export declare function mergeDeep(target: Record<string, any>, ...sources: any[]): Record<string, any>; export declare function mergeChromeOptions(base: Capabilities.ChromeOptions, override: Partial<Capabilities.ChromeOptions>): Capabilities.ChromeOptions; export {}; //# sourceMappingURL=util.d.ts.map