@wdio/browserstack-service 8.45.0 → 8.47.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/README.md +44 -11
- package/build/Percy/Percy-Handler.d.ts.map +1 -1
- package/build/Percy/Percy-Handler.js +4 -1
- package/build/Percy/Percy.d.ts.map +1 -1
- package/build/Percy/Percy.js +2 -1
- package/build/accessibility-handler.d.ts +9 -3
- package/build/accessibility-handler.d.ts.map +1 -1
- package/build/accessibility-handler.js +52 -11
- package/build/cleanup.js +3 -3
- package/build/cli/apiUtils.d.ts +14 -0
- package/build/cli/apiUtils.d.ts.map +1 -0
- package/build/cli/apiUtils.js +24 -0
- package/build/cli/cliLogger.d.ts +16 -0
- package/build/cli/cliLogger.d.ts.map +1 -0
- package/build/cli/cliLogger.js +70 -0
- package/build/cli/cliUtils.d.ts +46 -0
- package/build/cli/cliUtils.d.ts.map +1 -0
- package/build/cli/cliUtils.js +430 -0
- package/build/cli/eventDispatcher.d.ts +28 -0
- package/build/cli/eventDispatcher.d.ts.map +1 -0
- package/build/cli/eventDispatcher.js +48 -0
- package/build/cli/frameworks/automationFramework.d.ts +89 -0
- package/build/cli/frameworks/automationFramework.d.ts.map +1 -0
- package/build/cli/frameworks/automationFramework.js +131 -0
- package/build/cli/frameworks/constants/automationFrameworkConstants.d.ts +18 -0
- package/build/cli/frameworks/constants/automationFrameworkConstants.d.ts.map +1 -0
- package/build/cli/frameworks/constants/automationFrameworkConstants.js +17 -0
- package/build/cli/frameworks/constants/testFrameworkConstants.d.ts +43 -0
- package/build/cli/frameworks/constants/testFrameworkConstants.d.ts.map +1 -0
- package/build/cli/frameworks/constants/testFrameworkConstants.js +42 -0
- package/build/cli/frameworks/testFramework.d.ts +89 -0
- package/build/cli/frameworks/testFramework.d.ts.map +1 -0
- package/build/cli/frameworks/testFramework.js +125 -0
- package/build/cli/frameworks/wdioAutomationFramework.d.ts +28 -0
- package/build/cli/frameworks/wdioAutomationFramework.d.ts.map +1 -0
- package/build/cli/frameworks/wdioAutomationFramework.js +66 -0
- package/build/cli/frameworks/wdioMochaTestFramework.d.ts +82 -0
- package/build/cli/frameworks/wdioMochaTestFramework.d.ts.map +1 -0
- package/build/cli/frameworks/wdioMochaTestFramework.js +319 -0
- package/build/cli/grpcClient.d.ts +70 -0
- package/build/cli/grpcClient.d.ts.map +1 -0
- package/build/cli/grpcClient.js +419 -0
- package/build/cli/index.d.ts +148 -0
- package/build/cli/index.d.ts.map +1 -0
- package/build/cli/index.js +415 -0
- package/build/cli/instances/automationFrameworkInstance.d.ts +33 -0
- package/build/cli/instances/automationFrameworkInstance.d.ts.map +1 -0
- package/build/cli/instances/automationFrameworkInstance.js +44 -0
- package/build/cli/instances/testFrameworkInstance.d.ts +62 -0
- package/build/cli/instances/testFrameworkInstance.d.ts.map +1 -0
- package/build/cli/instances/testFrameworkInstance.js +96 -0
- package/build/cli/instances/trackedContext.d.ts +32 -0
- package/build/cli/instances/trackedContext.d.ts.map +1 -0
- package/build/cli/instances/trackedContext.js +47 -0
- package/build/cli/instances/trackedInstance.d.ts +40 -0
- package/build/cli/instances/trackedInstance.d.ts.map +1 -0
- package/build/cli/instances/trackedInstance.js +63 -0
- package/build/cli/modules/accessibilityModule.d.ts +33 -0
- package/build/cli/modules/accessibilityModule.d.ts.map +1 -0
- package/build/cli/modules/accessibilityModule.js +347 -0
- package/build/cli/modules/automateModule.d.ts +26 -0
- package/build/cli/modules/automateModule.d.ts.map +1 -0
- package/build/cli/modules/automateModule.js +222 -0
- package/build/cli/modules/baseModule.d.ts +33 -0
- package/build/cli/modules/baseModule.d.ts.map +1 -0
- package/build/cli/modules/baseModule.js +51 -0
- package/build/cli/modules/observabilityModule.d.ts +22 -0
- package/build/cli/modules/observabilityModule.d.ts.map +1 -0
- package/build/cli/modules/observabilityModule.js +45 -0
- package/build/cli/modules/percyModule.d.ts +19 -0
- package/build/cli/modules/percyModule.d.ts.map +1 -0
- package/build/cli/modules/percyModule.js +77 -0
- package/build/cli/modules/testHubModule.d.ts +30 -0
- package/build/cli/modules/testHubModule.d.ts.map +1 -0
- package/build/cli/modules/testHubModule.js +232 -0
- package/build/cli/modules/webdriverIOModule.d.ts +29 -0
- package/build/cli/modules/webdriverIOModule.d.ts.map +1 -0
- package/build/cli/modules/webdriverIOModule.js +128 -0
- package/build/cli/states/automationFrameworkState.d.ts +65 -0
- package/build/cli/states/automationFrameworkState.d.ts.map +1 -0
- package/build/cli/states/automationFrameworkState.js +61 -0
- package/build/cli/states/hookState.d.ts +45 -0
- package/build/cli/states/hookState.d.ts.map +1 -0
- package/build/cli/states/hookState.js +43 -0
- package/build/cli/states/testFrameworkState.d.ts +125 -0
- package/build/cli/states/testFrameworkState.d.ts.map +1 -0
- package/build/cli/states/testFrameworkState.js +115 -0
- package/build/constants.d.ts +13 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +21 -1
- package/build/crash-reporter.d.ts.map +1 -1
- package/build/crash-reporter.js +4 -3
- package/build/exitHandler.d.ts.map +1 -1
- package/build/exitHandler.js +47 -5
- package/build/insights-handler.d.ts +8 -0
- package/build/insights-handler.d.ts.map +1 -1
- package/build/insights-handler.js +57 -1
- package/build/instrumentation/funnelInstrumentation.d.ts.map +1 -1
- package/build/instrumentation/funnelInstrumentation.js +5 -4
- package/build/instrumentation/performance/constants.d.ts +8 -0
- package/build/instrumentation/performance/constants.d.ts.map +1 -1
- package/build/instrumentation/performance/constants.js +9 -1
- package/build/instrumentation/performance/performance-tester.d.ts.map +1 -1
- package/build/instrumentation/performance/performance-tester.js +5 -3
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +94 -51
- package/build/request-handler.js +1 -1
- package/build/service.d.ts +3 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +244 -69
- package/build/testOps/requestUtils.js +3 -2
- package/build/types.d.ts +36 -3
- package/build/types.d.ts.map +1 -1
- package/build/util.d.ts +13 -1
- package/build/util.d.ts.map +1 -1
- package/build/util.js +173 -27
- package/package.json +7 -4
- package/tsconfig.prod.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -28,8 +28,8 @@ export const config = {
|
|
|
28
28
|
key: process.env.BROWSERSTACK_ACCESS_KEY,
|
|
29
29
|
services: [
|
|
30
30
|
['browserstack', {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
testReporting: true,
|
|
32
|
+
testReportingOptions: {
|
|
33
33
|
projectName: "Your project name goes here",
|
|
34
34
|
buildName: "The static build job name goes here e.g. Nightly regression"
|
|
35
35
|
},
|
|
@@ -44,16 +44,15 @@ export const config = {
|
|
|
44
44
|
|
|
45
45
|
In order to authorize to the BrowserStack service your config needs to contain a [`user`](https://webdriver.io/docs/options#user) and [`key`](https://webdriver.io/docs/options#key) option.
|
|
46
46
|
|
|
47
|
-
### testObservability
|
|
47
|
+
### testReporting (formerly testObservability)
|
|
48
48
|
|
|
49
|
-
Test
|
|
49
|
+
Test Reporting and Analytics is an advanced test reporting tool that gives insights to improve your automation tests and helps you debug faster. It's enabled by default by setting the testReporting flag as true for all users of browserstack-service. You can disable this by setting the testReporting flag to false.
|
|
50
50
|
|
|
51
|
-
Once your tests finish running, you can visit [Test
|
|
51
|
+
Once your tests finish running, you can visit [Test Reporting and Analytics](https://automation.browserstack.com/?utm_source=webdriverio&utm_medium=partnered&utm_campaign=documentation) to debug your builds with additional insights like Unique Error Analysis, Automatic Flaky Test Detection, and more.
|
|
52
52
|
|
|
53
|
-
You can use Test
|
|
54
|
-
|
|
55
|
-
If you want to use Test Observability without running your tests on BrowserStack infrastructure, you can set your config as follows:
|
|
53
|
+
You can use Test Reporting and Analytics even if you don't run your tests on the BrowserStack infrastructure. Even if you run your tests on a CI, a local machine, or even on other cloud service providers, Test Reporting and Analytics can still generate intelligent test reports and advanced analytics on your tests.
|
|
56
54
|
|
|
55
|
+
If you want to use Test Reporting and Analytics without running your tests on BrowserStack infrastructure, you can set your config as follows:
|
|
57
56
|
|
|
58
57
|
```js
|
|
59
58
|
// wdio.conf.js
|
|
@@ -61,8 +60,29 @@ export const config = {
|
|
|
61
60
|
// ...
|
|
62
61
|
services: [
|
|
63
62
|
['browserstack', {
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
testReporting: true,
|
|
64
|
+
testReportingOptions: {
|
|
65
|
+
user: process.env.BROWSERSTACK_USERNAME,
|
|
66
|
+
key: process.env.BROWSERSTACK_ACCESS_KEY,
|
|
67
|
+
projectName: "Your project name goes here",
|
|
68
|
+
buildName: "The static build job name goes here e.g. Nightly regression"
|
|
69
|
+
}
|
|
70
|
+
}]
|
|
71
|
+
],
|
|
72
|
+
// ...
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For backward compatibility, the legacy `testObservability` and `testObservabilityOptions` flags are still supported:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
// wdio.conf.js (legacy configuration)
|
|
80
|
+
export const config = {
|
|
81
|
+
// ...
|
|
82
|
+
services: [
|
|
83
|
+
['browserstack', {
|
|
84
|
+
testObservability: true, // deprecated, use testReporting instead
|
|
85
|
+
testObservabilityOptions: { // deprecated, use testReportingOptions instead
|
|
66
86
|
user: process.env.BROWSERSTACK_USERNAME,
|
|
67
87
|
key: process.env.BROWSERSTACK_ACCESS_KEY,
|
|
68
88
|
projectName: "Your project name goes here",
|
|
@@ -74,7 +94,20 @@ export const config = {
|
|
|
74
94
|
};
|
|
75
95
|
```
|
|
76
96
|
|
|
77
|
-
|
|
97
|
+
#### Environment Variables
|
|
98
|
+
|
|
99
|
+
The following environment variables are supported:
|
|
100
|
+
|
|
101
|
+
**New (recommended):**
|
|
102
|
+
- `BROWSERSTACK_TEST_REPORTING` - Enable/disable test reporting
|
|
103
|
+
- `BROWSERSTACK_TEST_REPORTING_DEBUG` - Enable debug mode for test reporting
|
|
104
|
+
- `TEST_REPORTING_BUILD_TAG` - Comma-separated build tags
|
|
105
|
+
|
|
106
|
+
**Legacy (still supported):**
|
|
107
|
+
- `BROWSERSTACK_OBSERVABILITY` - Enable/disable test observability (deprecated)
|
|
108
|
+
- `TEST_OBSERVABILITY_BUILD_TAG` - Comma-separated build tags (deprecated)
|
|
109
|
+
|
|
110
|
+
You can explore all the features of Test Reporting and Analytics in [this sandbox](https://automation-demo.browserstack.com/?utm_source=webdriverio&utm_medium=partnered&utm_campaign=documentation) or read more about it [here](https://www.browserstack.com/docs/test-reporting/overview/what-is-test-reporting?utm_source=webdriverio&utm_medium=partnered&utm_campaign=documentation).
|
|
78
111
|
|
|
79
112
|
### browserstackLocal
|
|
80
113
|
Set this to true to enable routing connections from BrowserStack cloud through your computer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Percy-Handler.d.ts","sourceRoot":"","sources":["../../src/Percy/Percy-Handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAezE,cAAM,aAAa;IAUX,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,UAAU,CAAC;IAbvB,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,OAAO,CAAC,iCAAiC,CAAC,CAAiB;IAC3D,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,yBAAyB,CAAU;IAC3C,OAAO,CAAC,wBAAwB,CAAY;IAC5C,OAAO,CAAC,gBAAgB,CAAC,CAAiB;gBAG9B,qBAAqB,EAAE,MAAM,GAAG,SAAS,EACzC,QAAQ,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,EAC9D,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAC5C,cAAc,CAAC,EAAE,OAAO,YAAA,EACxB,UAAU,CAAC,EAAE,MAAM,Y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AC,IAAI,EAAE,iBAAiB,GAAG,OAAO;IA+BhD,0BAA0B;IAS1B,oBAAoB,CAAE,IAAI,EAAE,iBAAiB;IAoB7C,mBAAmB,CAAE,IAAI,EAAE,iBAAiB,GAAG,gBAAgB;IA0B/D,SAAS;IAMT,aAAa;CAKtB;AAGD,QAAA,MAAM,YAAY,EAAE,OAAO,aAAoD,CAAA;AAC/E,KAAK,YAAY,GAAG,aAAa,CAAA;AAEjC,eAAe,YAAY,CAAA"}
|
|
@@ -49,7 +49,10 @@ class _PercyHandler {
|
|
|
49
49
|
this._percyScreenshotCounter += 1;
|
|
50
50
|
}
|
|
51
51
|
this._percyCaptureMap?.increment(sessionName ? sessionName : this._sessionName, eventName);
|
|
52
|
-
|
|
52
|
+
const performanceEventName = this._isAppAutomate ? PERFORMANCE_SDK_EVENTS.PERCY_EVENTS.SCREENSHOT_APP : PERFORMANCE_SDK_EVENTS.PERCY_EVENTS.SCREENSHOT;
|
|
53
|
+
await PerformanceTester.measureWrapper(performanceEventName, async () => {
|
|
54
|
+
await (this._isAppAutomate ? PercySDK.screenshotApp(this._percyCaptureMap?.getName(sessionName ? sessionName : this._sessionName, eventName)) : await PercySDK.screenshot(this._browser, this._percyCaptureMap?.getName(sessionName ? sessionName : this._sessionName, eventName)));
|
|
55
|
+
})();
|
|
53
56
|
this._percyScreenshotCounter -= 1;
|
|
54
57
|
}
|
|
55
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Percy.d.ts","sourceRoot":"","sources":["../../src/Percy/Percy.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"Percy.d.ts","sourceRoot":"","sources":["../../src/Percy/Percy.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAQ1C,cAAM,KAAK;;IAWP,gBAAgB,UAAQ;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAO;IAC7B,gBAAgB,UAAQ;IACxB,KAAK,EAAE,OAAO,CAAA;gBAEF,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU;IAiBxG,WAAW;IAaX,KAAK;IA4CL,IAAI;IAWV,SAAS;IAIH,eAAe;IAoCf,iBAAiB;CA8B1B;AAED,eAAe,KAAK,CAAA"}
|
package/build/Percy/Percy.js
CHANGED
|
@@ -14,6 +14,7 @@ import PercyBinary from './PercyBinary.js';
|
|
|
14
14
|
import { BROWSERSTACK_TESTHUB_UUID } from '../constants.js';
|
|
15
15
|
import PerformanceTester from '../instrumentation/performance/performance-tester.js';
|
|
16
16
|
import * as PERFORMANCE_SDK_EVENTS from '../instrumentation/performance/constants.js';
|
|
17
|
+
import APIUtils from '../cli/apiUtils.js';
|
|
17
18
|
const logDir = 'logs';
|
|
18
19
|
class Percy {
|
|
19
20
|
#logfile = path.join(logDir, 'percy.log');
|
|
@@ -118,7 +119,7 @@ class Percy {
|
|
|
118
119
|
const response = await nodeRequest('GET', query, {
|
|
119
120
|
username: getBrowserStackUser(this.#config),
|
|
120
121
|
password: getBrowserStackKey(this.#config)
|
|
121
|
-
},
|
|
122
|
+
}, APIUtils.BROWSERSTACK_PERCY_API_URL);
|
|
122
123
|
PercyLogger.debug('Percy fetch token success : ' + response.token);
|
|
123
124
|
if (!this.#options.percy && response.success) {
|
|
124
125
|
this.percyAutoEnabled = response.success;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Capabilities, Frameworks, Options } from '@wdio/types';
|
|
2
2
|
import type { BrowserstackConfig, BrowserstackOptions } from './types.js';
|
|
3
3
|
import type { ITestCaseHookParameter } from './cucumber-types.js';
|
|
4
|
+
interface AccessibilityOptions {
|
|
5
|
+
includeIssueType?: string[];
|
|
6
|
+
excludeIssueType?: string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
4
9
|
declare class _AccessibilityHandler {
|
|
5
10
|
private _browser;
|
|
6
11
|
private _capabilities;
|
|
@@ -16,13 +21,13 @@ declare class _AccessibilityHandler {
|
|
|
16
21
|
private _options;
|
|
17
22
|
private _config;
|
|
18
23
|
private _accessibilityOptions?;
|
|
24
|
+
private _autoScanning;
|
|
25
|
+
private _testIdentifier;
|
|
19
26
|
private _testMetadata;
|
|
20
27
|
private static _a11yScanSessionMap;
|
|
21
28
|
private _sessionId;
|
|
22
29
|
private listener;
|
|
23
|
-
constructor(_browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, _capabilities: Capabilities.RemoteCapability, _options: BrowserstackConfig & BrowserstackOptions, isAppAutomate: boolean, _config: Options.Testrunner, _framework?: string | undefined, _accessibilityAutomation?: (boolean | string) | undefined, _turboscale?: boolean | string, _accessibilityOpts?:
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
} | undefined);
|
|
30
|
+
constructor(_browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, _capabilities: Capabilities.RemoteCapability, _options: BrowserstackConfig & BrowserstackOptions, isAppAutomate: boolean, _config: Options.Testrunner, _framework?: string | undefined, _accessibilityAutomation?: (boolean | string) | undefined, _turboscale?: boolean | string, _accessibilityOpts?: AccessibilityOptions | undefined);
|
|
26
31
|
setSuiteFile(filename: string): void;
|
|
27
32
|
_getCapabilityValue(caps: Capabilities.RemoteCapability, capType: string, legacyCapType: string): WebdriverIO.SafaridriverOptions | undefined;
|
|
28
33
|
before(sessionId: string): Promise<void>;
|
|
@@ -39,6 +44,7 @@ declare class _AccessibilityHandler {
|
|
|
39
44
|
private shouldRunTestHooks;
|
|
40
45
|
private checkIfPageOpened;
|
|
41
46
|
private static shouldPatchExecuteScript;
|
|
47
|
+
private _setAnnotation;
|
|
42
48
|
}
|
|
43
49
|
declare const AccessibilityHandler: typeof _AccessibilityHandler;
|
|
44
50
|
type AccessibilityHandler = _AccessibilityHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessibility-handler.d.ts","sourceRoot":"","sources":["../src/accessibility-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accessibility-handler.d.ts","sourceRoot":"","sources":["../src/accessibility-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAajE,UAAU,oBAAoB;IAC1B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB;AAqDD,cAAM,qBAAqB;IAiBnB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IAErB,OAAO,CAAC,aAAa;IAErB,OAAO,CAAC,UAAU,CAAC;IACnB,OAAO,CAAC,wBAAwB,CAAC;IAEjC,OAAO,CAAC,kBAAkB,CAAC;IAxB/B,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAA0C;IAC1D,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,qBAAqB,CAAC,CAAsB;IACpD,OAAO,C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;AACvG,KAAK,oBAAoB,GAAG,qBAAqB,CAAA;AAEjD,eAAe,oBAAoB,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/// <reference path="./@types/bstack-service-types.d.ts" />
|
|
1
2
|
import util from 'node:util';
|
|
2
3
|
import Listener from './testOps/listener.js';
|
|
3
|
-
import { getA11yResultsSummary, getAppA11yResultsSummary, getA11yResults, performA11yScan, getUniqueIdentifier, getUniqueIdentifierForCucumber, isAccessibilityAutomationSession, isAppAccessibilityAutomationSession, isBrowserstackSession, o11yClassErrorHandler, shouldScanTestForAccessibility, validateCapsWithA11y, shouldAddServiceVersion, validateCapsWithNonBstackA11y, isTrue, validateCapsWithAppA11y, getAppA11yResults } from './util.js';
|
|
4
|
+
import { getA11yResultsSummary, getAppA11yResultsSummary, getA11yResults, performA11yScan, getUniqueIdentifier, getUniqueIdentifierForCucumber, isAccessibilityAutomationSession, isAppAccessibilityAutomationSession, isBrowserstackSession, o11yClassErrorHandler, shouldScanTestForAccessibility, validateCapsWithA11y, shouldAddServiceVersion, validateCapsWithNonBstackA11y, isTrue, validateCapsWithAppA11y, getAppA11yResults, isFalse } from './util.js';
|
|
4
5
|
import accessibilityScripts from './scripts/accessibility-scripts.js';
|
|
5
6
|
import PerformanceTester from './instrumentation/performance/performance-tester.js';
|
|
6
7
|
import * as PERFORMANCE_SDK_EVENTS from './instrumentation/performance/constants.js';
|
|
@@ -20,6 +21,8 @@ class _AccessibilityHandler {
|
|
|
20
21
|
_options;
|
|
21
22
|
_config;
|
|
22
23
|
_accessibilityOptions;
|
|
24
|
+
_autoScanning = true;
|
|
25
|
+
_testIdentifier = null;
|
|
23
26
|
_testMetadata = {};
|
|
24
27
|
static _a11yScanSessionMap = {};
|
|
25
28
|
_sessionId = null;
|
|
@@ -43,6 +46,7 @@ class _AccessibilityHandler {
|
|
|
43
46
|
this._caps = _capabilities;
|
|
44
47
|
this._accessibility = isTrue(_accessibilityAutomation);
|
|
45
48
|
this._accessibilityOptions = _accessibilityOpts;
|
|
49
|
+
this._autoScanning = !isFalse(this._accessibilityOptions?.autoScanning);
|
|
46
50
|
this._options = _options;
|
|
47
51
|
this._config = _config;
|
|
48
52
|
this._turboscale = isTrue(_turboscale);
|
|
@@ -104,20 +108,42 @@ class _AccessibilityHandler {
|
|
|
104
108
|
this._accessibility = validateCapsWithAppA11y(this._platformA11yMeta);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
|
-
|
|
111
|
+
// Safely add accessibility methods to browser instance with proper typing
|
|
112
|
+
const browserWithA11y = this._browser;
|
|
113
|
+
browserWithA11y.getAccessibilityResultsSummary = async () => {
|
|
108
114
|
if (isAppAccessibilityAutomationSession(this._accessibility, this.isAppAutomate)) {
|
|
109
115
|
return await getAppA11yResultsSummary(this.isAppAutomate, this._browser, isBrowserstackSession(this._browser), this._accessibility, this._sessionId);
|
|
110
116
|
}
|
|
111
117
|
return await getA11yResultsSummary(this.isAppAutomate, this._browser, isBrowserstackSession(this._browser), this._accessibility);
|
|
112
118
|
};
|
|
113
|
-
|
|
119
|
+
browserWithA11y.getAccessibilityResults = async () => {
|
|
114
120
|
if (isAppAccessibilityAutomationSession(this._accessibility, this.isAppAutomate)) {
|
|
115
121
|
return await getAppA11yResults(this.isAppAutomate, this._browser, isBrowserstackSession(this._browser), this._accessibility, this._sessionId);
|
|
116
122
|
}
|
|
117
123
|
return await getA11yResults(this.isAppAutomate, this._browser, isBrowserstackSession(this._browser), this._accessibility);
|
|
118
124
|
};
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
browserWithA11y.performScan = async () => {
|
|
126
|
+
const results = await performA11yScan(this.isAppAutomate, this._browser, isBrowserstackSession(this._browser), this._accessibility);
|
|
127
|
+
if (results) {
|
|
128
|
+
this._testMetadata[this._testIdentifier] = {
|
|
129
|
+
scanTestForAccessibility: true,
|
|
130
|
+
accessibilityScanStarted: true
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
await this._setAnnotation('Accessibility scanning was triggered manually');
|
|
134
|
+
return results;
|
|
135
|
+
};
|
|
136
|
+
browserWithA11y.startA11yScanning = async () => {
|
|
137
|
+
AccessibilityHandler._a11yScanSessionMap[sessionId] = true;
|
|
138
|
+
this._testMetadata[this._testIdentifier] = {
|
|
139
|
+
scanTestForAccessibility: true,
|
|
140
|
+
accessibilityScanStarted: true
|
|
141
|
+
};
|
|
142
|
+
await this._setAnnotation('Accessibility scanning has started');
|
|
143
|
+
};
|
|
144
|
+
browserWithA11y.stopA11yScanning = async () => {
|
|
145
|
+
AccessibilityHandler._a11yScanSessionMap[sessionId] = false;
|
|
146
|
+
await this._setAnnotation('Accessibility scanning has stopped');
|
|
121
147
|
};
|
|
122
148
|
if (!this._accessibility) {
|
|
123
149
|
return;
|
|
@@ -140,8 +166,9 @@ class _AccessibilityHandler {
|
|
|
140
166
|
Listener.setTestRunAccessibilityVar(false);
|
|
141
167
|
return;
|
|
142
168
|
}
|
|
143
|
-
const shouldScanTest = shouldScanTestForAccessibility(suiteTitle, test.title, this._accessibilityOptions);
|
|
169
|
+
const shouldScanTest = this._autoScanning && shouldScanTestForAccessibility(suiteTitle, test.title, this._accessibilityOptions);
|
|
144
170
|
const testIdentifier = this.getIdentifier(test);
|
|
171
|
+
this._testIdentifier = testIdentifier;
|
|
145
172
|
if (this._sessionId) {
|
|
146
173
|
/* For case with multiple tests under one browser, before hook of 2nd test should change this map value */
|
|
147
174
|
AccessibilityHandler._a11yScanSessionMap[this._sessionId] = shouldScanTest;
|
|
@@ -197,13 +224,14 @@ class _AccessibilityHandler {
|
|
|
197
224
|
const gherkinDocument = world.gherkinDocument;
|
|
198
225
|
const featureData = gherkinDocument.feature;
|
|
199
226
|
const uniqueId = getUniqueIdentifierForCucumber(world);
|
|
227
|
+
this._testIdentifier = uniqueId;
|
|
200
228
|
if (!this.shouldRunTestHooks(this._browser, this._accessibility)) {
|
|
201
229
|
/* This is to be used when test events are sent */
|
|
202
230
|
Listener.setTestRunAccessibilityVar(false);
|
|
203
231
|
return;
|
|
204
232
|
}
|
|
205
233
|
try {
|
|
206
|
-
const shouldScanScenario = shouldScanTestForAccessibility(featureData?.name, pickleData.name, this._accessibilityOptions, world, true);
|
|
234
|
+
const shouldScanScenario = this._autoScanning && shouldScanTestForAccessibility(featureData?.name, pickleData.name, this._accessibilityOptions, world, true);
|
|
207
235
|
this._testMetadata[uniqueId] = {
|
|
208
236
|
scanTestForAccessibility: shouldScanScenario,
|
|
209
237
|
accessibilityScanStarted: true
|
|
@@ -264,10 +292,12 @@ class _AccessibilityHandler {
|
|
|
264
292
|
return origFunction(...args);
|
|
265
293
|
}
|
|
266
294
|
async sendTestStopEvent(browser, dataForExtension) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
await
|
|
270
|
-
|
|
295
|
+
if (AccessibilityHandler._a11yScanSessionMap[this._sessionId]) {
|
|
296
|
+
BStackLogger.debug('Performing scan before saving results');
|
|
297
|
+
await PerformanceTester.measureWrapper(PERFORMANCE_SDK_EVENTS.A11Y_EVENTS.PERFORM_SCAN, async () => {
|
|
298
|
+
await performA11yScan(this.isAppAutomate, browser, true, true);
|
|
299
|
+
}, { command: 'afterTest' })();
|
|
300
|
+
}
|
|
271
301
|
if (isAppAccessibilityAutomationSession(this._accessibility, this.isAppAutomate)) {
|
|
272
302
|
return;
|
|
273
303
|
}
|
|
@@ -311,6 +341,17 @@ class _AccessibilityHandler {
|
|
|
311
341
|
return (script.toLowerCase().indexOf('browserstack_executor') !== -1 ||
|
|
312
342
|
script.toLowerCase().indexOf('browserstack_accessibility_automation_script') !== -1);
|
|
313
343
|
}
|
|
344
|
+
async _setAnnotation(message) {
|
|
345
|
+
if (this._accessibility && isBrowserstackSession(this._browser)) {
|
|
346
|
+
await this._browser.execute(`browserstack_executor: ${JSON.stringify({
|
|
347
|
+
action: 'annotate',
|
|
348
|
+
arguments: {
|
|
349
|
+
data: message,
|
|
350
|
+
level: 'info'
|
|
351
|
+
}
|
|
352
|
+
})}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
314
355
|
}
|
|
315
356
|
// https://github.com/microsoft/TypeScript/issues/6543
|
|
316
357
|
const AccessibilityHandler = o11yClassErrorHandler(_AccessibilityHandler);
|
package/build/cleanup.js
CHANGED
|
@@ -40,19 +40,19 @@ export default class BStackCleanup {
|
|
|
40
40
|
if (!process.env[BROWSERSTACK_TESTHUB_JWT]) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
BStackLogger.debug('Executing
|
|
43
|
+
BStackLogger.debug('Executing Test Reporting and Analytics cleanup');
|
|
44
44
|
try {
|
|
45
45
|
const killSignal = funnelData?.event_properties?.finishedMetadata?.signal;
|
|
46
46
|
const result = await stopBuildUpstream(killSignal);
|
|
47
47
|
if (process.env[BROWSERSTACK_OBSERVABILITY] && process.env[BROWSERSTACK_TESTHUB_UUID]) {
|
|
48
|
-
BStackLogger.info(`\nVisit https://
|
|
48
|
+
BStackLogger.info(`\nVisit https://automation.browserstack.com/builds/${process.env[BROWSERSTACK_TESTHUB_UUID]} to view build report, insights, and many more debugging information all at one place!\n`);
|
|
49
49
|
}
|
|
50
50
|
const status = (result && result.status) || 'failed';
|
|
51
51
|
const message = (result && result.message);
|
|
52
52
|
this.updateO11yStopData(funnelData, status, status === 'failed' ? message : undefined);
|
|
53
53
|
}
|
|
54
54
|
catch (e) {
|
|
55
|
-
BStackLogger.error('Error in stopping
|
|
55
|
+
BStackLogger.error('Error in stopping Test Reporting and Analytics build: ' + e);
|
|
56
56
|
this.updateO11yStopData(funnelData, 'failed', e);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default class APIUtils {
|
|
2
|
+
static FUNNEL_INSTRUMENTATION_URL: string;
|
|
3
|
+
static BROWSERSTACK_AUTOMATE_API_URL: string;
|
|
4
|
+
static BROWSERSTACK_AA_API_URL: string;
|
|
5
|
+
static BROWSERSTACK_PERCY_API_URL: string;
|
|
6
|
+
static BROWSERSTACK_AUTOMATE_API_CLOUD_URL: string;
|
|
7
|
+
static BROWSERSTACK_AA_API_CLOUD_URL: string;
|
|
8
|
+
static APP_ALLY_ENDPOINT: string;
|
|
9
|
+
static DATA_ENDPOINT: string;
|
|
10
|
+
static UPLOAD_LOGS_ADDRESS: string;
|
|
11
|
+
static EDS_URL: string;
|
|
12
|
+
static updateURLSForGRR(apis: GRRUrls): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=apiUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiUtils.d.ts","sourceRoot":"","sources":["../../src/cli/apiUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,MAAM,CAAC,0BAA0B,SAA8C;IAC/E,MAAM,CAAC,6BAA6B,SAAiC;IACrE,MAAM,CAAC,uBAAuB,SAAiC;IAC/D,MAAM,CAAC,0BAA0B,SAAiC;IAClE,MAAM,CAAC,mCAAmC,SAAuC;IACjF,MAAM,CAAC,6BAA6B,SAAuC;IAC3E,MAAM,CAAC,iBAAiB,SAAwD;IAChF,MAAM,CAAC,aAAa,SAAqD;IACzE,MAAM,CAAC,mBAAmB,SAAkD;IAC5E,MAAM,CAAC,OAAO,SAAiC;IAE/C,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO;CAYxC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default class APIUtils {
|
|
2
|
+
static FUNNEL_INSTRUMENTATION_URL = 'https://api.browserstack.com/sdk/v1/event';
|
|
3
|
+
static BROWSERSTACK_AUTOMATE_API_URL = 'https://api.browserstack.com';
|
|
4
|
+
static BROWSERSTACK_AA_API_URL = 'https://api.browserstack.com';
|
|
5
|
+
static BROWSERSTACK_PERCY_API_URL = 'https://api.browserstack.com';
|
|
6
|
+
static BROWSERSTACK_AUTOMATE_API_CLOUD_URL = 'https://api-cloud.browserstack.com';
|
|
7
|
+
static BROWSERSTACK_AA_API_CLOUD_URL = 'https://api-cloud.browserstack.com';
|
|
8
|
+
static APP_ALLY_ENDPOINT = 'https://app-accessibility.browserstack.com/automate';
|
|
9
|
+
static DATA_ENDPOINT = 'https://collector-observability.browserstack.com';
|
|
10
|
+
static UPLOAD_LOGS_ADDRESS = 'https://upload-observability.browserstack.com';
|
|
11
|
+
static EDS_URL = 'https://eds.browserstack.com';
|
|
12
|
+
static updateURLSForGRR(apis) {
|
|
13
|
+
this.FUNNEL_INSTRUMENTATION_URL = `${apis.automate.api}/sdk/v1/event`;
|
|
14
|
+
this.BROWSERSTACK_AUTOMATE_API_URL = apis.automate.api;
|
|
15
|
+
this.BROWSERSTACK_AA_API_URL = apis.appAutomate.api;
|
|
16
|
+
this.BROWSERSTACK_PERCY_API_URL = apis.percy.api;
|
|
17
|
+
this.BROWSERSTACK_AUTOMATE_API_CLOUD_URL = apis.automate.upload;
|
|
18
|
+
this.BROWSERSTACK_AA_API_CLOUD_URL = apis.appAutomate.upload;
|
|
19
|
+
this.APP_ALLY_ENDPOINT = `${apis.appAccessibility.api}/automate`;
|
|
20
|
+
this.DATA_ENDPOINT = apis.observability.api;
|
|
21
|
+
this.UPLOAD_LOGS_ADDRESS = apis.observability.upload;
|
|
22
|
+
this.EDS_URL = apis.edsInstrumentation.api;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class BStackLogger {
|
|
2
|
+
static logFilePath: string;
|
|
3
|
+
static logFolderPath: string;
|
|
4
|
+
private static logFileStream;
|
|
5
|
+
static logToFile(logMessage: string, logLevel: string): void;
|
|
6
|
+
private static formatLog;
|
|
7
|
+
static info(message: string): void;
|
|
8
|
+
static error(message: string): void;
|
|
9
|
+
static debug(message: string, param?: unknown): void;
|
|
10
|
+
static warn(message: string): void;
|
|
11
|
+
static trace(message: string): void;
|
|
12
|
+
static clearLogger(): void;
|
|
13
|
+
static clearLogFile(): void;
|
|
14
|
+
static ensureLogsFolder(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=cliLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliLogger.d.ts","sourceRoot":"","sources":["../../src/cli/cliLogger.ts"],"names":[],"mappings":"AAWA,qBAAa,YAAY;IACrB,OAAc,WAAW,SAAsC;IAC/D,OAAc,aAAa,SAAmC;IAC9D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAuB;IAEnD,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAcrD,OAAO,CAAC,MAAM,CAAC,SAAS;WAIV,IAAI,CAAC,OAAO,EAAE,MAAM;WAKpB,KAAK,CAAC,OAAO,EAAE,MAAM;WAKrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;WAStC,IAAI,CAAC,OAAO,EAAE,MAAM;WAKpB,KAAK,CAAC,OAAO,EAAE,MAAM;WAKrB,WAAW;WAOX,YAAY;WAMZ,gBAAgB;CAKjC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import logger from '@wdio/logger';
|
|
5
|
+
import { LOGS_FILE } from '../constants.js';
|
|
6
|
+
import { COLORS } from '../util.js';
|
|
7
|
+
const log = logger('@wdio/browserstack-service/cli');
|
|
8
|
+
export class BStackLogger {
|
|
9
|
+
static logFilePath = path.join(process.cwd(), LOGS_FILE);
|
|
10
|
+
static logFolderPath = path.join(process.cwd(), 'logs');
|
|
11
|
+
static logFileStream;
|
|
12
|
+
static logToFile(logMessage, logLevel) {
|
|
13
|
+
try {
|
|
14
|
+
if (!this.logFileStream) {
|
|
15
|
+
this.ensureLogsFolder();
|
|
16
|
+
this.logFileStream = fs.createWriteStream(this.logFilePath, { flags: 'a' });
|
|
17
|
+
}
|
|
18
|
+
if (this.logFileStream && this.logFileStream.writable) {
|
|
19
|
+
this.logFileStream.write(this.formatLog(logMessage, logLevel));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
log.debug(`Failed to log to file. Error ${error}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static formatLog(logMessage, level) {
|
|
27
|
+
return `${chalk.gray(new Date().toISOString())} ${chalk[COLORS[level]](level.toUpperCase())} ${chalk.whiteBright('@wdio/browserstack-service')} ${logMessage}\n`;
|
|
28
|
+
}
|
|
29
|
+
static info(message) {
|
|
30
|
+
this.logToFile(message, 'info');
|
|
31
|
+
log.info(message);
|
|
32
|
+
}
|
|
33
|
+
static error(message) {
|
|
34
|
+
this.logToFile(message, 'error');
|
|
35
|
+
log.error(message);
|
|
36
|
+
}
|
|
37
|
+
static debug(message, param) {
|
|
38
|
+
this.logToFile(message, 'debug');
|
|
39
|
+
if (param) {
|
|
40
|
+
log.debug(message, param);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
log.debug(message);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
static warn(message) {
|
|
47
|
+
this.logToFile(message, 'warn');
|
|
48
|
+
log.warn(message);
|
|
49
|
+
}
|
|
50
|
+
static trace(message) {
|
|
51
|
+
this.logToFile(message, 'trace');
|
|
52
|
+
log.trace(message);
|
|
53
|
+
}
|
|
54
|
+
static clearLogger() {
|
|
55
|
+
if (this.logFileStream) {
|
|
56
|
+
this.logFileStream.end();
|
|
57
|
+
}
|
|
58
|
+
this.logFileStream = null;
|
|
59
|
+
}
|
|
60
|
+
static clearLogFile() {
|
|
61
|
+
if (fs.existsSync(this.logFilePath)) {
|
|
62
|
+
fs.truncateSync(this.logFilePath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
static ensureLogsFolder() {
|
|
66
|
+
if (!fs.existsSync(this.logFolderPath)) {
|
|
67
|
+
fs.mkdirSync(this.logFolderPath);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import type { Options, Capabilities } from '@wdio/types';
|
|
3
|
+
import type { BrowserstackConfig, BrowserstackOptions, TestObservabilityOptions } from '../types.js';
|
|
4
|
+
export declare class CLIUtils {
|
|
5
|
+
static automationFrameworkDetail: {};
|
|
6
|
+
static testFrameworkDetail: {};
|
|
7
|
+
static CLISupportedFrameworks: string[];
|
|
8
|
+
static isDevelopmentEnv(): boolean;
|
|
9
|
+
static getCLIParamsForDevEnv(): Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Build config object for binary session request
|
|
12
|
+
* @returns {string}
|
|
13
|
+
* @throws {Error}
|
|
14
|
+
*/
|
|
15
|
+
static getBinConfig(config: Options.Testrunner, capabilities: Capabilities.RemoteCapabilities, options: BrowserstackConfig & BrowserstackOptions, buildTag?: string): string;
|
|
16
|
+
static getSdkVersion(): any;
|
|
17
|
+
static getSdkLanguage(): string;
|
|
18
|
+
static setupCliPath(config: Options.Testrunner): Promise<string | null>;
|
|
19
|
+
static checkAndUpdateCli(existingCliPath: string, cliDir: string, config: Options.Testrunner): Promise<string | null>;
|
|
20
|
+
static getCliDir(): string;
|
|
21
|
+
static getWritableDir(): string | null | undefined;
|
|
22
|
+
static getExistingCliPath(cliDir: string): string;
|
|
23
|
+
static requestToUpdateCLI: (queryParams: Record<string, string>, config: Options.Testrunner) => Promise<any>;
|
|
24
|
+
static runShellCommand(cmdCommand: string, workingDir?: string): Promise<string>;
|
|
25
|
+
static downloadLatestBinary: (binDownloadUrl: string, cliDir: string) => Promise<string | null>;
|
|
26
|
+
static downloadFileStream(downloadedFileStream: fs.WriteStream, binaryName: string | null, zipFilePath: string, cliDir: string, resolve: (path: string) => void, reject: (reason?: Error) => void): void;
|
|
27
|
+
static getTestFrameworkDetail(): any;
|
|
28
|
+
static getAutomationFrameworkDetail(): any;
|
|
29
|
+
static setFrameworkDetail(testFramework: string, automationFramework: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the current instance name using thread id and processId
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
static getCurrentInstanceName(): string;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param {TestFrameworkState | AutomationFrameworkState} frameworkState
|
|
38
|
+
* @param {HookState} hookState
|
|
39
|
+
* @returns {string}
|
|
40
|
+
*/
|
|
41
|
+
static getHookRegistryKey(frameworkState: State, hookState: State): string;
|
|
42
|
+
static matchHookRegex(hookState: string): boolean;
|
|
43
|
+
static getObservabilityBuildTags(observabilityOptions: TestObservabilityOptions, bstackBuildTag?: string): string[];
|
|
44
|
+
static checkCLISupportedFrameworks(framework: string | undefined): boolean;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=cliUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliUtils.d.ts","sourceRoot":"","sources":["../../src/cli/cliUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AAiCxB,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAIpG,qBAAa,QAAQ;IACjB,MAAM,CAAC,yBAAyB,KAAK;IACrC,MAAM,CAAC,mBAAmB,KAAK;IAC/B,MAAM,CAAC,sBAAsB,WAAY;IAEzC,MAAM,CAAC,gBAAgB;IAIvB,MAAM,CAAC,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAOtD;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,YAAY,CAAC,kBAAkB,EAAE,OAAO,EAAE,kBAAkB,GAAG,mBAAmB,EAAE,QAAQ,CAAC,EAAE,MAAM;IA2EnK,MAAM,CAAC,aAAa;IAIpB,M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