@wdio/browserstack-service 8.41.0 → 8.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Percy/Percy-Handler.d.ts.map +1 -1
- package/build/Percy/Percy-Handler.js +5 -0
- package/build/Percy/Percy.d.ts.map +1 -1
- package/build/Percy/Percy.js +14 -0
- package/build/Percy/PercyBinary.d.ts.map +1 -1
- package/build/Percy/PercyBinary.js +11 -0
- package/build/Percy/PercySDK.d.ts.map +1 -1
- package/build/Percy/PercySDK.js +3 -6
- package/build/accessibility-handler.d.ts +2 -1
- package/build/accessibility-handler.d.ts.map +1 -1
- package/build/accessibility-handler.js +45 -21
- package/build/cleanup.d.ts.map +1 -1
- package/build/cleanup.js +10 -0
- package/build/config.d.ts.map +1 -1
- package/build/config.js +2 -0
- package/build/constants.d.ts +5 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +5 -0
- package/build/exitHandler.d.ts.map +1 -1
- package/build/exitHandler.js +8 -0
- package/build/instrumentation/funnelInstrumentation.d.ts.map +1 -1
- package/build/instrumentation/funnelInstrumentation.js +6 -1
- package/build/instrumentation/performance/constants.d.ts +79 -0
- package/build/instrumentation/performance/constants.d.ts.map +1 -0
- package/build/instrumentation/performance/constants.js +78 -0
- package/build/instrumentation/performance/performance-tester.d.ts +44 -0
- package/build/instrumentation/performance/performance-tester.d.ts.map +1 -0
- package/build/instrumentation/performance/performance-tester.js +280 -0
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +29 -5
- package/build/scripts/accessibility-scripts.d.ts +1 -0
- package/build/scripts/accessibility-scripts.d.ts.map +1 -1
- package/build/scripts/accessibility-scripts.js +27 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +68 -14
- package/build/util.d.ts +26 -9
- package/build/util.d.ts.map +1 -1
- package/build/util.js +207 -37
- package/package.json +6 -6
- package/tsconfig.prod.tsbuildinfo +1 -1
- package/build/performance-tester.d.ts +0 -14
- package/build/performance-tester.d.ts.map +0 -1
- package/build/performance-tester.js +0 -94
package/build/service.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
1
7
|
import got from 'got';
|
|
2
|
-
import PerformanceTester from './performance-tester.js';
|
|
3
8
|
import { getBrowserDescription, getBrowserCapabilities, isBrowserstackCapability, getParentSuiteName, isBrowserstackSession, patchConsoleLogs, shouldAddServiceVersion, isTrue } from './util.js';
|
|
4
9
|
import InsightsHandler from './insights-handler.js';
|
|
5
10
|
import TestReporter from './reporter.js';
|
|
@@ -13,6 +18,8 @@ import { saveWorkerData } from './data-store.js';
|
|
|
13
18
|
import UsageStats from './testOps/usageStats.js';
|
|
14
19
|
import { shouldProcessEventForTesthub } from './testHub/utils.js';
|
|
15
20
|
import AiHandler from './ai-handler.js';
|
|
21
|
+
import PerformanceTester from './instrumentation/performance/performance-tester.js';
|
|
22
|
+
import * as PERFORMANCE_SDK_EVENTS from './instrumentation/performance/constants.js';
|
|
16
23
|
export default class BrowserstackService {
|
|
17
24
|
_caps;
|
|
18
25
|
_config;
|
|
@@ -46,11 +53,9 @@ export default class BrowserstackService {
|
|
|
46
53
|
this._percy = isTrue(process.env.BROWSERSTACK_PERCY);
|
|
47
54
|
this._percyCaptureMode = process.env.BROWSERSTACK_PERCY_CAPTURE_MODE;
|
|
48
55
|
this._turboScale = this._options.turboScale;
|
|
56
|
+
PerformanceTester.startMonitoring('performance-report-service.csv');
|
|
49
57
|
if (shouldProcessEventForTesthub('')) {
|
|
50
58
|
this._config.reporters?.push(TestReporter);
|
|
51
|
-
if (process.env[PERF_MEASUREMENT_ENV]) {
|
|
52
|
-
PerformanceTester.startMonitoring('performance-report-service.csv');
|
|
53
|
-
}
|
|
54
59
|
}
|
|
55
60
|
if (process.env.BROWSERSTACK_TURBOSCALE) {
|
|
56
61
|
this._turboScale = process.env.BROWSERSTACK_TURBOSCALE === 'true';
|
|
@@ -90,6 +95,7 @@ export default class BrowserstackService {
|
|
|
90
95
|
async before(caps, specs, browser) {
|
|
91
96
|
// added to maintain backward compatibility with webdriverIO v5
|
|
92
97
|
this._browser = browser ? browser : globalThis.browser;
|
|
98
|
+
PerformanceTester.browser = this._browser;
|
|
93
99
|
// Healing Support:
|
|
94
100
|
if (!shouldAddServiceVersion(this._config, this._options.testObservability, caps)) {
|
|
95
101
|
try {
|
|
@@ -109,6 +115,7 @@ export default class BrowserstackService {
|
|
|
109
115
|
this._sessionBaseUrl = 'https://api.browserstack.com/automate-turboscale/v1/sessions';
|
|
110
116
|
}
|
|
111
117
|
this._scenariosThatRan = [];
|
|
118
|
+
PerformanceTester.scenarioThatRan = [...(this._scenariosThatRan ?? [])];
|
|
112
119
|
if (this._browser) {
|
|
113
120
|
try {
|
|
114
121
|
const sessionId = this._browser.sessionId;
|
|
@@ -219,20 +226,22 @@ export default class BrowserstackService {
|
|
|
219
226
|
if (preferScenarioName && this._scenariosThatRan.length === 1) {
|
|
220
227
|
this._fullTitle = this._scenariosThatRan.pop();
|
|
221
228
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
await PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.AUTOMATE_EVENTS.SESSION_STATUS, async () => {
|
|
230
|
+
if (setSessionStatus) {
|
|
231
|
+
const hasReasons = this._failReasons.length > 0;
|
|
232
|
+
await this._updateJob({
|
|
233
|
+
status: result === 0 && this._specsRan ? 'passed' : 'failed',
|
|
234
|
+
...(setSessionName ? { name: this._fullTitle } : {}),
|
|
235
|
+
...(result === 0 && this._specsRan ?
|
|
236
|
+
{} : hasReasons ? { reason: this._failReasons.join('\n') } : {})
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
})();
|
|
231
240
|
await Listener.getInstance().onWorkerEnd();
|
|
232
241
|
await this._percyHandler?.teardown();
|
|
233
242
|
this.saveWorkerData();
|
|
243
|
+
await PerformanceTester.stopAndGenerate('performance-service.html');
|
|
234
244
|
if (process.env[PERF_MEASUREMENT_ENV]) {
|
|
235
|
-
await PerformanceTester.stopAndGenerate('performance-service.html');
|
|
236
245
|
PerformanceTester.calculateTimes([
|
|
237
246
|
'onRunnerStart', 'onSuiteStart', 'onSuiteEnd',
|
|
238
247
|
'onTestStart', 'onTestEnd', 'onTestSkip', 'before',
|
|
@@ -434,3 +443,48 @@ export default class BrowserstackService {
|
|
|
434
443
|
});
|
|
435
444
|
}
|
|
436
445
|
}
|
|
446
|
+
__decorate([
|
|
447
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'beforeSession' })
|
|
448
|
+
], BrowserstackService.prototype, "beforeSession", null);
|
|
449
|
+
__decorate([
|
|
450
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'before' })
|
|
451
|
+
], BrowserstackService.prototype, "before", null);
|
|
452
|
+
__decorate([
|
|
453
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'beforeSuite' })
|
|
454
|
+
], BrowserstackService.prototype, "beforeSuite", null);
|
|
455
|
+
__decorate([
|
|
456
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'beforeHook' })
|
|
457
|
+
], BrowserstackService.prototype, "beforeHook", null);
|
|
458
|
+
__decorate([
|
|
459
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'afterHook' })
|
|
460
|
+
], BrowserstackService.prototype, "afterHook", null);
|
|
461
|
+
__decorate([
|
|
462
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'beforeTest' })
|
|
463
|
+
], BrowserstackService.prototype, "beforeTest", null);
|
|
464
|
+
__decorate([
|
|
465
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'afterTest' })
|
|
466
|
+
], BrowserstackService.prototype, "afterTest", null);
|
|
467
|
+
__decorate([
|
|
468
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'after' })
|
|
469
|
+
], BrowserstackService.prototype, "after", null);
|
|
470
|
+
__decorate([
|
|
471
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'beforeFeature' })
|
|
472
|
+
], BrowserstackService.prototype, "beforeFeature", null);
|
|
473
|
+
__decorate([
|
|
474
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'beforeScenario' })
|
|
475
|
+
], BrowserstackService.prototype, "beforeScenario", null);
|
|
476
|
+
__decorate([
|
|
477
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'afterScenario' })
|
|
478
|
+
], BrowserstackService.prototype, "afterScenario", null);
|
|
479
|
+
__decorate([
|
|
480
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'beforeStep' })
|
|
481
|
+
], BrowserstackService.prototype, "beforeStep", null);
|
|
482
|
+
__decorate([
|
|
483
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'afterStep' })
|
|
484
|
+
], BrowserstackService.prototype, "afterStep", null);
|
|
485
|
+
__decorate([
|
|
486
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.EVENTS.SDK_HOOK, { hookType: 'onReload' })
|
|
487
|
+
], BrowserstackService.prototype, "onReload", null);
|
|
488
|
+
__decorate([
|
|
489
|
+
PerformanceTester.Measure(PERFORMANCE_SDK_EVENTS.AUTOMATE_EVENTS.PRINT_BUILDLINK)
|
|
490
|
+
], BrowserstackService.prototype, "_printSessionURL", null);
|
package/build/util.d.ts
CHANGED
|
@@ -70,7 +70,10 @@ interface DataElement {
|
|
|
70
70
|
export declare const jsonifyAccessibilityArray: (dataArray: DataElement[], keyName: keyof DataElement, valueName: keyof DataElement) => Record<string, any>;
|
|
71
71
|
export declare const processAccessibilityResponse: (response: LaunchResponse) => void;
|
|
72
72
|
export declare const processLaunchBuildResponse: (response: LaunchResponse, options: BrowserstackConfig & Options.Testrunner) => void;
|
|
73
|
-
export declare const launchTestSession: (...args: any) => any;
|
|
73
|
+
export declare const launchTestSession: (...args: any[]) => any;
|
|
74
|
+
export declare const validateCapsWithAppA11y: (platformMeta?: {
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
}) => boolean;
|
|
74
77
|
export declare const validateCapsWithA11y: (deviceName?: any, platformMeta?: {
|
|
75
78
|
[key: string]: any;
|
|
76
79
|
}, chromeOptions?: any) => boolean;
|
|
@@ -80,16 +83,24 @@ export declare const shouldScanTestForAccessibility: (suiteTitle: string | undef
|
|
|
80
83
|
[key: string]: any;
|
|
81
84
|
}, isCucumber?: boolean) => boolean;
|
|
82
85
|
export declare const isAccessibilityAutomationSession: (accessibilityFlag?: boolean | string) => boolean | "" | undefined;
|
|
83
|
-
export declare const
|
|
86
|
+
export declare const isAppAccessibilityAutomationSession: (accessibilityFlag?: boolean | string, isAppAutomate?: boolean) => boolean | "" | undefined;
|
|
87
|
+
export declare const formatString: (template: (string | null), ...values: (string | null)[]) => string;
|
|
88
|
+
export declare const _getParamsForAppAccessibility: (commandName?: string) => {
|
|
89
|
+
thTestRunUuid: any;
|
|
90
|
+
thBuildUuid: any;
|
|
91
|
+
thJwtToken: any;
|
|
92
|
+
authHeader: any;
|
|
93
|
+
scanTimestamp: Number;
|
|
94
|
+
method: string | undefined;
|
|
95
|
+
};
|
|
96
|
+
export declare const performA11yScan: (isAppAutomate: boolean, browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, isBrowserStackSession?: boolean, isAccessibility?: boolean | string, commandName?: string) => Promise<{
|
|
84
97
|
[key: string]: any;
|
|
85
98
|
} | undefined>;
|
|
86
|
-
export declare const getA11yResults: (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
export declare const getA11yResultsSummary: (
|
|
90
|
-
|
|
91
|
-
}>;
|
|
92
|
-
export declare const stopBuildUpstream: (...args: any) => any;
|
|
99
|
+
export declare const getA11yResults: (...args: any[]) => any;
|
|
100
|
+
export declare const getAppA11yResults: (...args: any[]) => any;
|
|
101
|
+
export declare const getAppA11yResultsSummary: (...args: any[]) => any;
|
|
102
|
+
export declare const getA11yResultsSummary: (...args: any[]) => any;
|
|
103
|
+
export declare const stopBuildUpstream: (...args: any[]) => any;
|
|
93
104
|
export declare function getCiInfo(): {
|
|
94
105
|
name: string;
|
|
95
106
|
build_url: string | undefined;
|
|
@@ -175,5 +186,11 @@ export declare const hasBrowserName: (cap: Options.Testrunner) => boolean;
|
|
|
175
186
|
export declare const isValidCapsForHealing: (caps: {
|
|
176
187
|
[key: string]: Options.Testrunner;
|
|
177
188
|
}) => boolean;
|
|
189
|
+
type PollingResult = {
|
|
190
|
+
data: any;
|
|
191
|
+
headers: Record<string, any>;
|
|
192
|
+
message?: string;
|
|
193
|
+
};
|
|
194
|
+
export declare function pollApi(url: string, params: Record<string, any>, headers: Record<string, string>, upperLimit: number, startTime?: number): Promise<PollingResult>;
|
|
178
195
|
export {};
|
|
179
196
|
//# sourceMappingURL=util.d.ts.map
|
package/build/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,MAAM,YAAY,CAAA;AAI9B,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAIjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,MAAM,YAAY,CAAA;AAI9B,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAIjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAStC,OAAO,KAAK,EAAc,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAc,MAAM,YAAY,CAAA;AACxG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AA+BjE,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC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from 'gitconfiglocal';
|
|
12
12
|
import { FormData } from 'formdata-node';
|
|
13
|
+
import { performance } from 'node:perf_hooks';
|
|
13
14
|
import logPatcher from './logPatcher.js';
|
|
14
|
-
import PerformanceTester from './performance-tester.js';
|
|
15
|
+
import PerformanceTester from './instrumentation/performance/performance-tester.js';
|
|
16
|
+
import * as PERFORMANCE_SDK_EVENTS from './instrumentation/performance/constants.js';
|
|
15
17
|
import { getProductMap, logBuildError, handleErrorForObservability, handleErrorForAccessibility } from './testHub/utils.js';
|
|
16
|
-
import { BROWSER_DESCRIPTION, DATA_ENDPOINT, UPLOAD_LOGS_ADDRESS, UPLOAD_LOGS_ENDPOINT, consoleHolder, TESTOPS_SCREENSHOT_ENV, BROWSERSTACK_TESTHUB_UUID, PERF_MEASUREMENT_ENV, RERUN_ENV, TESTOPS_BUILD_COMPLETED_ENV, BROWSERSTACK_TESTHUB_JWT, BROWSERSTACK_OBSERVABILITY, BROWSERSTACK_ACCESSIBILITY, MAX_GIT_META_DATA_SIZE_IN_BYTES, GIT_META_DATA_TRUNCATED } from './constants.js';
|
|
18
|
+
import { BROWSER_DESCRIPTION, DATA_ENDPOINT, UPLOAD_LOGS_ADDRESS, UPLOAD_LOGS_ENDPOINT, consoleHolder, BSTACK_A11Y_POLLING_TIMEOUT, TESTOPS_SCREENSHOT_ENV, BROWSERSTACK_TESTHUB_UUID, PERF_MEASUREMENT_ENV, RERUN_ENV, TESTOPS_BUILD_COMPLETED_ENV, BROWSERSTACK_TESTHUB_JWT, BROWSERSTACK_OBSERVABILITY, BROWSERSTACK_ACCESSIBILITY, MAX_GIT_META_DATA_SIZE_IN_BYTES, GIT_META_DATA_TRUNCATED, APP_ALLY_ENDPOINT, APP_ALLY_ISSUES_SUMMARY_ENDPOINT, APP_ALLY_ISSUES_ENDPOINT } from './constants.js';
|
|
17
19
|
import CrashReporter from './crash-reporter.js';
|
|
18
20
|
import { BStackLogger } from './bstackLogger.js';
|
|
19
21
|
import { FileStream } from './fileStream.js';
|
|
@@ -110,7 +112,7 @@ export function o11yErrorHandler(fn) {
|
|
|
110
112
|
try {
|
|
111
113
|
let functionToHandle = fn;
|
|
112
114
|
if (process.env[PERF_MEASUREMENT_ENV]) {
|
|
113
|
-
functionToHandle =
|
|
115
|
+
functionToHandle = performance.timerify(functionToHandle);
|
|
114
116
|
}
|
|
115
117
|
const result = functionToHandle(...args);
|
|
116
118
|
if (result instanceof Promise) {
|
|
@@ -188,7 +190,7 @@ export function o11yClassErrorHandler(errorClass) {
|
|
|
188
190
|
writable: true,
|
|
189
191
|
value: function (...args) {
|
|
190
192
|
try {
|
|
191
|
-
const result = (process.env[PERF_MEASUREMENT_ENV] ?
|
|
193
|
+
const result = (process.env[PERF_MEASUREMENT_ENV] ? performance.timerify(method) : method).call(this, ...args);
|
|
192
194
|
if (result instanceof Promise) {
|
|
193
195
|
return result.catch(error => processError(error, method, args));
|
|
194
196
|
}
|
|
@@ -234,19 +236,22 @@ export const processAccessibilityResponse = (response) => {
|
|
|
234
236
|
return;
|
|
235
237
|
}
|
|
236
238
|
if (response.accessibility.options) {
|
|
237
|
-
const { accessibilityToken, scannerVersion } = jsonifyAccessibilityArray(response.accessibility.options.capabilities, 'name', 'value');
|
|
239
|
+
const { accessibilityToken, pollingTimeout, scannerVersion } = jsonifyAccessibilityArray(response.accessibility.options.capabilities, 'name', 'value');
|
|
238
240
|
const scriptsJson = {
|
|
239
241
|
'scripts': jsonifyAccessibilityArray(response.accessibility.options.scripts, 'name', 'command'),
|
|
240
242
|
'commands': response.accessibility.options.commandsToWrap.commands
|
|
241
243
|
};
|
|
242
244
|
if (scannerVersion) {
|
|
243
245
|
process.env.BSTACK_A11Y_SCANNER_VERSION = scannerVersion;
|
|
246
|
+
BStackLogger.debug(`Accessibility scannerVersion ${scannerVersion}`);
|
|
244
247
|
}
|
|
245
|
-
BStackLogger.debug(`Accessibility scannerVersion ${scannerVersion}`);
|
|
246
248
|
if (accessibilityToken) {
|
|
247
249
|
process.env.BSTACK_A11Y_JWT = accessibilityToken;
|
|
248
250
|
process.env[BROWSERSTACK_ACCESSIBILITY] = 'true';
|
|
249
251
|
}
|
|
252
|
+
if (pollingTimeout) {
|
|
253
|
+
process.env.BSTACK_A11Y_POLLING_TIMEOUT = pollingTimeout;
|
|
254
|
+
}
|
|
250
255
|
if (scriptsJson) {
|
|
251
256
|
AccessibilityScripts.update(scriptsJson);
|
|
252
257
|
AccessibilityScripts.store();
|
|
@@ -261,7 +266,7 @@ export const processLaunchBuildResponse = (response, options) => {
|
|
|
261
266
|
processAccessibilityResponse(response);
|
|
262
267
|
}
|
|
263
268
|
};
|
|
264
|
-
export const launchTestSession = o11yErrorHandler(async function launchTestSession(options, config, bsConfig, bStackConfig) {
|
|
269
|
+
export const launchTestSession = PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.TESTHUB_EVENTS.START, o11yErrorHandler(async function launchTestSession(options, config, bsConfig, bStackConfig) {
|
|
265
270
|
const launchBuildUsage = UsageStats.getInstance().launchBuildUsage;
|
|
266
271
|
launchBuildUsage.triggered();
|
|
267
272
|
const data = {
|
|
@@ -324,6 +329,7 @@ export const launchTestSession = o11yErrorHandler(async function launchTestSessi
|
|
|
324
329
|
if (response.build_hashed_id) {
|
|
325
330
|
process.env[BROWSERSTACK_TESTHUB_UUID] = response.build_hashed_id;
|
|
326
331
|
TestOpsConfig.getInstance().buildHashedId = response.build_hashed_id;
|
|
332
|
+
BStackLogger.info(`Testhub started with id: ${TestOpsConfig.getInstance().buildHashedId}`);
|
|
327
333
|
}
|
|
328
334
|
processLaunchBuildResponse(response, options);
|
|
329
335
|
launchBuildUsage.success();
|
|
@@ -335,7 +341,19 @@ export const launchTestSession = o11yErrorHandler(async function launchTestSessi
|
|
|
335
341
|
return;
|
|
336
342
|
}
|
|
337
343
|
}
|
|
338
|
-
});
|
|
344
|
+
}));
|
|
345
|
+
export const validateCapsWithAppA11y = (platformMeta) => {
|
|
346
|
+
/* Check if the current driver platform is eligible for AppAccessibility scan */
|
|
347
|
+
BStackLogger.debug(`platformMeta ${JSON.stringify(platformMeta)}`);
|
|
348
|
+
if (platformMeta?.platform_name &&
|
|
349
|
+
String(platformMeta?.platform_name).toLowerCase() === 'android' &&
|
|
350
|
+
platformMeta?.platform_version &&
|
|
351
|
+
parseInt(platformMeta?.platform_version?.toString()) < 11) {
|
|
352
|
+
BStackLogger.warn('App Accessibility Automation tests are supported on OS version 11 and above for Android devices.');
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
return true;
|
|
356
|
+
};
|
|
339
357
|
export const validateCapsWithA11y = (deviceName, platformMeta, chromeOptions) => {
|
|
340
358
|
/* Check if the current driver platform is eligible for Accessibility scan */
|
|
341
359
|
try {
|
|
@@ -394,26 +412,57 @@ export const isAccessibilityAutomationSession = (accessibilityFlag) => {
|
|
|
394
412
|
}
|
|
395
413
|
return false;
|
|
396
414
|
};
|
|
397
|
-
export const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
try {
|
|
407
|
-
const results = await browser.executeAsync(AccessibilityScripts.performScan, { 'method': commandName || '' });
|
|
408
|
-
BStackLogger.debug(util.format(results));
|
|
409
|
-
return results;
|
|
410
|
-
}
|
|
411
|
-
catch (err) {
|
|
412
|
-
BStackLogger.error('Accessibility Scan could not be performed : ' + err);
|
|
413
|
-
return;
|
|
415
|
+
export const isAppAccessibilityAutomationSession = (accessibilityFlag, isAppAutomate) => {
|
|
416
|
+
const accessibilityAutomation = isAccessibilityAutomationSession(accessibilityFlag);
|
|
417
|
+
return accessibilityAutomation && isAppAutomate;
|
|
418
|
+
};
|
|
419
|
+
export const formatString = (template, ...values) => {
|
|
420
|
+
let i = 0;
|
|
421
|
+
if (template === null) {
|
|
422
|
+
return '';
|
|
414
423
|
}
|
|
424
|
+
return template.replace(/%s/g, () => {
|
|
425
|
+
const value = values[i++];
|
|
426
|
+
return value !== null && value !== undefined ? value : '';
|
|
427
|
+
});
|
|
428
|
+
};
|
|
429
|
+
export const _getParamsForAppAccessibility = (commandName) => {
|
|
430
|
+
return {
|
|
431
|
+
'thTestRunUuid': process.env.TEST_ANALYTICS_ID,
|
|
432
|
+
'thBuildUuid': process.env.BROWSERSTACK_TESTHUB_UUID,
|
|
433
|
+
'thJwtToken': process.env.BROWSERSTACK_TESTHUB_JWT,
|
|
434
|
+
'authHeader': process.env.BSTACK_A11Y_JWT,
|
|
435
|
+
'scanTimestamp': Date.now(),
|
|
436
|
+
'method': commandName
|
|
437
|
+
};
|
|
415
438
|
};
|
|
416
|
-
export const
|
|
439
|
+
export const performA11yScan = async (isAppAutomate, browser, isBrowserStackSession, isAccessibility, commandName) => {
|
|
440
|
+
return await PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.A11Y_EVENTS.PERFORM_SCAN, async () => {
|
|
441
|
+
if (!isBrowserStackSession) {
|
|
442
|
+
BStackLogger.warn('Not a BrowserStack Automate session, cannot perform Accessibility scan.');
|
|
443
|
+
return; // since we are running only on Automate as of now
|
|
444
|
+
}
|
|
445
|
+
if (!isAccessibilityAutomationSession(isAccessibility)) {
|
|
446
|
+
BStackLogger.warn('Not an Accessibility Automation session, cannot perform Accessibility scan.');
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
try {
|
|
450
|
+
if (isAppAccessibilityAutomationSession(isAccessibility, isAppAutomate)) {
|
|
451
|
+
const results = await browser.execute(formatString(AccessibilityScripts.performScan, JSON.stringify(_getParamsForAppAccessibility(commandName))), {});
|
|
452
|
+
BStackLogger.debug(util.format(results));
|
|
453
|
+
return results;
|
|
454
|
+
}
|
|
455
|
+
const results = await browser.executeAsync(AccessibilityScripts.performScan, { 'method': commandName || '' });
|
|
456
|
+
BStackLogger.debug(util.format(results));
|
|
457
|
+
return results;
|
|
458
|
+
}
|
|
459
|
+
catch (err) {
|
|
460
|
+
BStackLogger.error('Accessibility Scan could not be performed : ' + err);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
}, { command: commandName })();
|
|
464
|
+
};
|
|
465
|
+
export const getA11yResults = PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.A11Y_EVENTS.GET_RESULTS, async (isAppAutomate, browser, isBrowserStackSession, isAccessibility) => {
|
|
417
466
|
if (!isBrowserStackSession) {
|
|
418
467
|
BStackLogger.warn('Not a BrowserStack Automate session, cannot retrieve Accessibility results.');
|
|
419
468
|
return []; // since we are running only on Automate as of now
|
|
@@ -424,16 +473,68 @@ export const getA11yResults = async (browser, isBrowserStackSession, isAccessibi
|
|
|
424
473
|
}
|
|
425
474
|
try {
|
|
426
475
|
BStackLogger.debug('Performing scan before getting results');
|
|
427
|
-
await performA11yScan(browser, isBrowserStackSession, isAccessibility);
|
|
476
|
+
await performA11yScan(isAppAutomate, browser, isBrowserStackSession, isAccessibility);
|
|
428
477
|
const results = await browser.executeAsync(AccessibilityScripts.getResults);
|
|
429
478
|
return results;
|
|
430
479
|
}
|
|
431
|
-
catch {
|
|
480
|
+
catch (error) {
|
|
432
481
|
BStackLogger.error('No accessibility results were found.');
|
|
482
|
+
BStackLogger.debug(`getA11yResults Failed. Error: ${error}`);
|
|
433
483
|
return [];
|
|
434
484
|
}
|
|
485
|
+
});
|
|
486
|
+
export const getAppA11yResults = PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.A11Y_EVENTS.GET_RESULTS, async (isAppAutomate, browser, isBrowserStackSession, isAccessibility, sessionId) => {
|
|
487
|
+
if (!isBrowserStackSession) {
|
|
488
|
+
return []; // since we are running only on Automate as of now
|
|
489
|
+
}
|
|
490
|
+
if (!isAppAccessibilityAutomationSession(isAccessibility, isAppAutomate)) {
|
|
491
|
+
BStackLogger.warn('Not an Accessibility Automation session, cannot retrieve Accessibility results summary.');
|
|
492
|
+
return [];
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
const apiUrl = `${APP_ALLY_ENDPOINT}/${APP_ALLY_ISSUES_ENDPOINT}`;
|
|
496
|
+
const apiRespone = await getAppA11yResultResponse(apiUrl, isAppAutomate, browser, isBrowserStackSession, isAccessibility, sessionId);
|
|
497
|
+
const result = apiRespone?.data?.data?.issues;
|
|
498
|
+
BStackLogger.debug(`Polling Result: ${JSON.stringify(result)}`);
|
|
499
|
+
return result;
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
BStackLogger.error('No accessibility summary was found.');
|
|
503
|
+
BStackLogger.debug(`getAppA11yResults Failed. Error: ${error}`);
|
|
504
|
+
return [];
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
export const getAppA11yResultsSummary = PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.A11Y_EVENTS.GET_RESULTS_SUMMARY, async (isAppAutomate, browser, isBrowserStackSession, isAccessibility, sessionId) => {
|
|
508
|
+
if (!isBrowserStackSession) {
|
|
509
|
+
return {}; // since we are running only on Automate as of now
|
|
510
|
+
}
|
|
511
|
+
if (!isAppAccessibilityAutomationSession(isAccessibility, isAppAutomate)) {
|
|
512
|
+
BStackLogger.warn('Not an Accessibility Automation session, cannot retrieve Accessibility results summary.');
|
|
513
|
+
return {};
|
|
514
|
+
}
|
|
515
|
+
try {
|
|
516
|
+
const apiUrl = `${APP_ALLY_ENDPOINT}/${APP_ALLY_ISSUES_SUMMARY_ENDPOINT}`;
|
|
517
|
+
const apiRespone = await getAppA11yResultResponse(apiUrl, isAppAutomate, browser, isBrowserStackSession, isAccessibility, sessionId);
|
|
518
|
+
const result = apiRespone?.data?.data?.summary;
|
|
519
|
+
BStackLogger.debug(`Polling Result: ${JSON.stringify(result)}`);
|
|
520
|
+
return result;
|
|
521
|
+
}
|
|
522
|
+
catch {
|
|
523
|
+
BStackLogger.error('No accessibility summary was found.');
|
|
524
|
+
return {};
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
const getAppA11yResultResponse = async (apiUrl, isAppAutomate, browser, isBrowserStackSession, isAccessibility, sessionId) => {
|
|
528
|
+
BStackLogger.debug('Performing scan before getting results summary');
|
|
529
|
+
await performA11yScan(isAppAutomate, browser, isBrowserStackSession, isAccessibility);
|
|
530
|
+
const upperTimeLimit = process.env[BSTACK_A11Y_POLLING_TIMEOUT] ? Date.now() + parseInt(process.env[BSTACK_A11Y_POLLING_TIMEOUT]) * 1000 : Date.now() + 30000;
|
|
531
|
+
const params = { test_run_uuid: process.env.TEST_ANALYTICS_ID, session_id: sessionId, timestamp: Date.now() }; // Query params to pass
|
|
532
|
+
const header = { Authorization: `Bearer ${process.env.BSTACK_A11Y_JWT}` };
|
|
533
|
+
const apiRespone = await pollApi(apiUrl, params, header, upperTimeLimit);
|
|
534
|
+
BStackLogger.debug(`Polling Result: ${JSON.stringify(apiRespone)}`);
|
|
535
|
+
return apiRespone;
|
|
435
536
|
};
|
|
436
|
-
export const getA11yResultsSummary = async (browser, isBrowserStackSession, isAccessibility) => {
|
|
537
|
+
export const getA11yResultsSummary = PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.A11Y_EVENTS.GET_RESULTS_SUMMARY, async (isAppAutomate, browser, isBrowserStackSession, isAccessibility) => {
|
|
437
538
|
if (!isBrowserStackSession) {
|
|
438
539
|
return {}; // since we are running only on Automate as of now
|
|
439
540
|
}
|
|
@@ -443,7 +544,7 @@ export const getA11yResultsSummary = async (browser, isBrowserStackSession, isAc
|
|
|
443
544
|
}
|
|
444
545
|
try {
|
|
445
546
|
BStackLogger.debug('Performing scan before getting results summary');
|
|
446
|
-
await performA11yScan(browser, isBrowserStackSession, isAccessibility);
|
|
547
|
+
await performA11yScan(isAppAutomate, browser, isBrowserStackSession, isAccessibility);
|
|
447
548
|
const summaryResults = await browser.executeAsync(AccessibilityScripts.getResultsSummary);
|
|
448
549
|
return summaryResults;
|
|
449
550
|
}
|
|
@@ -451,8 +552,8 @@ export const getA11yResultsSummary = async (browser, isBrowserStackSession, isAc
|
|
|
451
552
|
BStackLogger.error('No accessibility summary was found.');
|
|
452
553
|
return {};
|
|
453
554
|
}
|
|
454
|
-
};
|
|
455
|
-
export const stopBuildUpstream = o11yErrorHandler(async function stopBuildUpstream(killSignal = null) {
|
|
555
|
+
});
|
|
556
|
+
export const stopBuildUpstream = PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.TESTHUB_EVENTS.STOP, o11yErrorHandler(async function stopBuildUpstream(killSignal = null) {
|
|
456
557
|
const stopBuildUsage = UsageStats.getInstance().stopBuildUsage;
|
|
457
558
|
stopBuildUsage.triggered();
|
|
458
559
|
if (!process.env[TESTOPS_BUILD_COMPLETED_ENV]) {
|
|
@@ -510,7 +611,7 @@ export const stopBuildUpstream = o11yErrorHandler(async function stopBuildUpstre
|
|
|
510
611
|
message: error.message
|
|
511
612
|
};
|
|
512
613
|
}
|
|
513
|
-
});
|
|
614
|
+
}));
|
|
514
615
|
export function getCiInfo() {
|
|
515
616
|
const env = process.env;
|
|
516
617
|
// Jenkins
|
|
@@ -1042,14 +1143,27 @@ export function frameworkSupportsHook(hook, framework) {
|
|
|
1042
1143
|
export const patchConsoleLogs = o11yErrorHandler(() => {
|
|
1043
1144
|
const BSTestOpsPatcher = new logPatcher({});
|
|
1044
1145
|
Object.keys(consoleHolder).forEach((method) => {
|
|
1146
|
+
if (!(method in console) || typeof console[method] !== 'function') {
|
|
1147
|
+
BStackLogger.debug(`Skipping method: ${method}, exists: ${method in console}, type: ${typeof console[method]}`);
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1045
1150
|
const origMethod = console[method].bind(console);
|
|
1046
1151
|
// Make sure we don't override Constructors
|
|
1047
1152
|
// Arrow functions are not construable
|
|
1048
|
-
if (typeof console[method] === 'function'
|
|
1049
|
-
&& method !== 'Console') {
|
|
1153
|
+
if (typeof console[method] === 'function' && method !== 'Console') {
|
|
1050
1154
|
console[method] = (...args) => {
|
|
1051
|
-
|
|
1052
|
-
|
|
1155
|
+
try {
|
|
1156
|
+
if (!Object.keys(BSTestOpsPatcher).includes(method)) {
|
|
1157
|
+
origMethod(...args);
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1160
|
+
origMethod(...args);
|
|
1161
|
+
BSTestOpsPatcher[method](...args);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
catch (error) {
|
|
1165
|
+
origMethod(...args);
|
|
1166
|
+
}
|
|
1053
1167
|
};
|
|
1054
1168
|
}
|
|
1055
1169
|
});
|
|
@@ -1193,3 +1307,59 @@ export const isValidCapsForHealing = (caps) => {
|
|
|
1193
1307
|
// Check if there are any capabilities and if at least one has a browser name
|
|
1194
1308
|
return capValues.length > 0 && capValues.some(hasBrowserName);
|
|
1195
1309
|
};
|
|
1310
|
+
export async function pollApi(url, params, headers, upperLimit, startTime = Date.now()) {
|
|
1311
|
+
params.timestamp = Math.round(Date.now() / 1000);
|
|
1312
|
+
BStackLogger.debug(`current timestamp ${params.timestamp}`);
|
|
1313
|
+
try {
|
|
1314
|
+
const response = await got(url, {
|
|
1315
|
+
searchParams: params,
|
|
1316
|
+
headers,
|
|
1317
|
+
});
|
|
1318
|
+
const responseData = JSON.parse(response.body);
|
|
1319
|
+
return {
|
|
1320
|
+
data: responseData,
|
|
1321
|
+
headers: response.headers,
|
|
1322
|
+
message: 'Polling succeeded.',
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
catch (error) {
|
|
1326
|
+
if (error.response && error.response.statusCode === 404) {
|
|
1327
|
+
const nextPollTime = parseInt(error.response.headers.next_poll_time, 10) * 1000;
|
|
1328
|
+
BStackLogger.debug(`timeInMillis ${nextPollTime}`);
|
|
1329
|
+
if (isNaN(nextPollTime)) {
|
|
1330
|
+
BStackLogger.warn('Invalid or missing `nextPollTime` header. Stopping polling.');
|
|
1331
|
+
return {
|
|
1332
|
+
data: {},
|
|
1333
|
+
headers: error.response.headers,
|
|
1334
|
+
message: 'Invalid nextPollTime header value. Polling stopped.',
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
const elapsedTime = nextPollTime - Date.now();
|
|
1338
|
+
BStackLogger.debug(`elapsedTime ${elapsedTime} timeInMillis ${nextPollTime} upperLimit ${upperLimit}`);
|
|
1339
|
+
// Stop polling if the upper time limit is reached
|
|
1340
|
+
if (nextPollTime > upperLimit) {
|
|
1341
|
+
BStackLogger.warn('Polling stopped due to upper time limit.');
|
|
1342
|
+
return {
|
|
1343
|
+
data: {},
|
|
1344
|
+
headers: error.response.headers,
|
|
1345
|
+
message: 'Polling stopped due to upper time limit.',
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
BStackLogger.debug(`Polling again in ${elapsedTime}ms with params:`, params);
|
|
1349
|
+
// Wait for the specified time and poll again
|
|
1350
|
+
await new Promise((resolve) => setTimeout(resolve, elapsedTime));
|
|
1351
|
+
return pollApi(url, params, headers, upperLimit, startTime);
|
|
1352
|
+
}
|
|
1353
|
+
else if (error.response) {
|
|
1354
|
+
throw {
|
|
1355
|
+
data: {},
|
|
1356
|
+
headers: {},
|
|
1357
|
+
message: error.response.body ? JSON.parse(error.response.body).message : 'Unknown error',
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
else {
|
|
1361
|
+
BStackLogger.error(`Unexpected error occurred: ${error}`);
|
|
1362
|
+
return { data: {}, headers: {}, message: 'Unexpected error occurred.' };
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browserstack-service",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.43.0",
|
|
4
4
|
"description": "WebdriverIO service for better Browserstack integration",
|
|
5
5
|
"author": "Adam Bjerstedt <abjerstedt@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-browserstack-service",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
},
|
|
31
31
|
"typeScriptVersion": "3.8.3",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@browserstack/ai-sdk-node": "1.5.
|
|
33
|
+
"@browserstack/ai-sdk-node": "1.5.17",
|
|
34
34
|
"@percy/appium-app": "^2.0.1",
|
|
35
35
|
"@percy/selenium-webdriver": "^2.0.3",
|
|
36
36
|
"@types/gitconfiglocal": "^2.0.1",
|
|
37
37
|
"@wdio/logger": "8.38.0",
|
|
38
|
-
"@wdio/reporter": "8.
|
|
38
|
+
"@wdio/reporter": "8.43.0",
|
|
39
39
|
"@wdio/types": "8.41.0",
|
|
40
40
|
"browserstack-local": "^1.5.1",
|
|
41
41
|
"chalk": "^5.3.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"gitconfiglocal": "^2.1.0",
|
|
46
46
|
"got": "^12.6.1",
|
|
47
47
|
"uuid": "^10.0.0",
|
|
48
|
-
"webdriverio": "8.
|
|
48
|
+
"webdriverio": "8.43.0",
|
|
49
49
|
"winston-transport": "^4.5.0",
|
|
50
50
|
"yauzl": "^3.0.0"
|
|
51
51
|
},
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^22.2.0",
|
|
57
|
-
"@wdio/globals": "8.
|
|
57
|
+
"@wdio/globals": "8.43.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "f3783f61e0c62001cda71231fb4d947951f6f10d"
|
|
63
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/accessibility-handler.ts","./src/ai-handler.ts","./src/bstackLogger.ts","./src/cleanup.ts","./src/config.ts","./src/constants.ts","./src/crash-reporter.ts","./src/cucumber-types.ts","./src/data-store.ts","./src/exitHandler.ts","./src/fileStream.ts","./src/index.ts","./src/insights-handler.ts","./src/launcher.ts","./src/log4jsAppender.ts","./src/logPatcher.ts","./src/logReportingAPI.ts","./src/
|
|
1
|
+
{"root":["./src/accessibility-handler.ts","./src/ai-handler.ts","./src/bstackLogger.ts","./src/cleanup.ts","./src/config.ts","./src/constants.ts","./src/crash-reporter.ts","./src/cucumber-types.ts","./src/data-store.ts","./src/exitHandler.ts","./src/fileStream.ts","./src/index.ts","./src/insights-handler.ts","./src/launcher.ts","./src/log4jsAppender.ts","./src/logPatcher.ts","./src/logReportingAPI.ts","./src/reporter.ts","./src/request-handler.ts","./src/service.ts","./src/types.ts","./src/util.ts","./src/@types/bstack-service-types.d.ts","./src/@types/cucumber-framework.d.ts","./src/Percy/Percy-Handler.ts","./src/Percy/Percy.ts","./src/Percy/PercyBinary.ts","./src/Percy/PercyCaptureMap.ts","./src/Percy/PercyHelper.ts","./src/Percy/PercyLogger.ts","./src/Percy/PercySDK.ts","./src/instrumentation/funnelInstrumentation.ts","./src/instrumentation/performance/constants.ts","./src/instrumentation/performance/performance-tester.ts","./src/scripts/accessibility-scripts.ts","./src/testHub/utils.ts","./src/testOps/featureStats.ts","./src/testOps/featureUsage.ts","./src/testOps/listener.ts","./src/testOps/requestUtils.ts","./src/testOps/testOpsConfig.ts","./src/testOps/usageStats.ts","../../@types/css-shorthand-properties.d.ts","../../@types/css-value.d.ts","../../@types/custom.d.ts","../../@types/junit-report-builder.d.ts","../../@types/lerna-changelog.d.ts","../../@types/query-selector-shadow-dom.d.ts"],"version":"5.6.2"}
|