@wdio/browserstack-service 7.35.0 → 7.37.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/accessibility-handler.d.ts +5 -3
- package/build/accessibility-handler.d.ts.map +1 -1
- package/build/accessibility-handler.js +61 -30
- package/build/bstackLogger.d.ts +14 -0
- package/build/bstackLogger.d.ts.map +1 -0
- package/build/bstackLogger.js +52 -0
- package/build/cleanup.d.ts +6 -2
- package/build/cleanup.d.ts.map +1 -1
- package/build/cleanup.js +104 -12
- package/build/config.d.ts +23 -0
- package/build/config.d.ts.map +1 -0
- package/build/config.js +32 -0
- package/build/constants.d.ts +17 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +34 -1
- package/build/crash-reporter.js +1 -1
- package/build/data-store.d.ts +3 -0
- package/build/data-store.d.ts.map +1 -0
- package/build/data-store.js +49 -0
- package/build/exitHandler.d.ts +4 -0
- package/build/exitHandler.d.ts.map +1 -0
- package/build/exitHandler.js +37 -0
- package/build/insights-handler.d.ts +7 -12
- package/build/insights-handler.d.ts.map +1 -1
- package/build/insights-handler.js +49 -107
- package/build/instrumentation/funnelInstrumentation.d.ts +6 -0
- package/build/instrumentation/funnelInstrumentation.d.ts.map +1 -0
- package/build/instrumentation/funnelInstrumentation.js +127 -0
- package/build/launcher.d.ts +1 -2
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +21 -20
- package/build/reporter.d.ts +5 -3
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +17 -23
- package/build/request-handler.d.ts +5 -13
- package/build/request-handler.d.ts.map +1 -1
- package/build/request-handler.js +27 -48
- package/build/scripts/accessibility-scripts.d.ts +26 -0
- package/build/scripts/accessibility-scripts.d.ts.map +1 -0
- package/build/scripts/accessibility-scripts.js +67 -0
- package/build/service.d.ts +1 -0
- package/build/service.d.ts.map +1 -1
- package/build/service.js +24 -16
- package/build/testOps/featureStats.d.ts +45 -0
- package/build/testOps/featureStats.d.ts.map +1 -0
- package/build/testOps/featureStats.js +120 -0
- package/build/testOps/featureUsage.d.ts +22 -0
- package/build/testOps/featureUsage.d.ts.map +1 -0
- package/build/testOps/featureUsage.js +46 -0
- package/build/testOps/listener.d.ts +33 -0
- package/build/testOps/listener.d.ts.map +1 -0
- package/build/testOps/listener.js +228 -0
- package/build/testOps/requestUtils.d.ts +4 -0
- package/build/testOps/requestUtils.d.ts.map +1 -0
- package/build/testOps/requestUtils.js +47 -0
- package/build/testOps/testOpsConfig.d.ts +11 -0
- package/build/testOps/testOpsConfig.d.ts.map +1 -0
- package/build/testOps/testOpsConfig.js +17 -0
- package/build/testOps/usageStats.d.ts +404 -0
- package/build/testOps/usageStats.d.ts.map +1 -0
- package/build/testOps/usageStats.js +110 -0
- package/build/types.d.ts +34 -7
- package/build/types.d.ts.map +1 -1
- package/build/util.d.ts +6 -6
- package/build/util.d.ts.map +1 -1
- package/build/util.js +114 -71
- package/package.json +3 -3
|
@@ -13,12 +13,14 @@ declare class _AccessibilityHandler {
|
|
|
13
13
|
private _accessibility?;
|
|
14
14
|
private _accessibilityOptions?;
|
|
15
15
|
private _testMetadata;
|
|
16
|
+
private static _a11yScanSessionMap;
|
|
17
|
+
private _sessionId;
|
|
16
18
|
constructor(_browser: Browser<'async'> | MultiRemoteBrowser<'async'>, _capabilities: Capabilities.RemoteCapability, isAppAutomate?: boolean, _framework?: string | undefined, _accessibilityAutomation?: string | boolean | undefined, _accessibilityOpts?: {
|
|
17
19
|
[key: string]: any;
|
|
18
20
|
} | undefined);
|
|
19
21
|
setSuiteFile(filename: string): void;
|
|
20
22
|
_getCapabilityValue(caps: Capabilities.RemoteCapability, capType: string, legacyCapType: string): any;
|
|
21
|
-
before(): Promise<void>;
|
|
23
|
+
before(sessionId: string): Promise<void>;
|
|
22
24
|
beforeTest(suiteTitle: string | undefined, test: Frameworks.Test): Promise<void>;
|
|
23
25
|
afterTest(suiteTitle: string | undefined, test: Frameworks.Test): Promise<void>;
|
|
24
26
|
/**
|
|
@@ -26,12 +28,12 @@ declare class _AccessibilityHandler {
|
|
|
26
28
|
*/
|
|
27
29
|
beforeScenario(world: ITestCaseHookParameter): Promise<void>;
|
|
28
30
|
afterScenario(world: ITestCaseHookParameter): Promise<void>;
|
|
29
|
-
private
|
|
30
|
-
private sendTestForceStopEvent;
|
|
31
|
+
private commandWrapper;
|
|
31
32
|
private sendTestStopEvent;
|
|
32
33
|
private getIdentifier;
|
|
33
34
|
private shouldRunTestHooks;
|
|
34
35
|
private checkIfPageOpened;
|
|
36
|
+
private static shouldPatchExecuteScript;
|
|
35
37
|
}
|
|
36
38
|
declare const AccessibilityHandler: typeof _AccessibilityHandler;
|
|
37
39
|
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,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAqB9D,cAAM,qBAAqB;IAWnB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IAErB,OAAO,CAAC,UAAU,CAAC;IACnB,OAAO,CAAC,wBAAwB,CAAC;IACjC,OAAO,CAAC,kBAAkB,CAAC;IAf/B,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,qBAAqB,CAAC,CAAyB;IACvD,OAAO,CAAC,aAAa,CAA8B;IACnD,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAA8B;IAChE,OAAO,CAAC,UAAU,CAAsB;gBAG5B,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,EACxD,aAAa,EAAE,YAAY,CAAC,gBAAgB,EACpD,aAAa,CAAC,EAAE,OAAO,EACf,UAAU,CAAC,oBAAQ,EACnB,wBAAwB,CAAC,8BAAkB,EAC3C,kBAAkB,CAAC;;iBAAyB;IAgBxD,YAAY,CAAC,QAAQ,EAAE,MAAM;IAI7B,mBAAmB,CAAC,IAAI,EAAE,YAAY,CAAC,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAI,GAAG;IA6BhG,MAAM,CAAE,SAAS,EAAE,MAAM;IAyCzB,UAAU,CAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI;IAiCjE,SAAS,CAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI;IA0CtE;;MAEE;IACI,cAAc,CAAE,KAAK,EAAE,sBAAsB;IAgC7C,aAAa,CAAE,KAAK,EAAE,sBAAsB;YA8CpC,cAAc;YAcd,iBAAiB;IAO/B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,kBAAkB;YAOZ,iBAAiB;IAkB/B,OAAO,CAAC,MAAM,CAAC,wBAAwB;CAU1C;AAGD,QAAA,MAAM,oBAAoB,EAAE,OAAO,qBAAoE,CAAA;AACvG,KAAK,oBAAoB,GAAG,qBAAqB,CAAA;AAEjD,eAAe,oBAAoB,CAAA"}
|
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
6
7
|
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
7
8
|
const util_1 = require("./util");
|
|
8
|
-
const
|
|
9
|
+
const accessibility_scripts_1 = __importDefault(require("./scripts/accessibility-scripts"));
|
|
9
10
|
const log = (0, logger_1.default)('@wdio/browserstack-service');
|
|
10
11
|
class _AccessibilityHandler {
|
|
11
12
|
constructor(_browser, _capabilities, isAppAutomate, _framework, _accessibilityAutomation, _accessibilityOpts) {
|
|
@@ -15,6 +16,7 @@ class _AccessibilityHandler {
|
|
|
15
16
|
this._accessibilityAutomation = _accessibilityAutomation;
|
|
16
17
|
this._accessibilityOpts = _accessibilityOpts;
|
|
17
18
|
this._testMetadata = {};
|
|
19
|
+
this._sessionId = null;
|
|
18
20
|
const caps = this._browser.capabilities;
|
|
19
21
|
this._platformA11yMeta = {
|
|
20
22
|
browser_name: caps.browserName,
|
|
@@ -65,7 +67,8 @@ class _AccessibilityHandler {
|
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
|
-
async before() {
|
|
70
|
+
async before(sessionId) {
|
|
71
|
+
this._sessionId = sessionId;
|
|
69
72
|
this._accessibility = (0, util_1.isTrue)(this._getCapabilityValue(this._caps, 'accessibility', 'browserstack.accessibility'));
|
|
70
73
|
if ((0, util_1.isBrowserstackSession)(this._browser) && (0, util_1.isAccessibilityAutomationSession)(this._accessibility)) {
|
|
71
74
|
const deviceName = this._getCapabilityValue(this._caps, 'deviceName', 'device');
|
|
@@ -78,6 +81,26 @@ class _AccessibilityHandler {
|
|
|
78
81
|
this._browser.getAccessibilityResults = async () => {
|
|
79
82
|
return await (0, util_1.getA11yResults)(this._browser, (0, util_1.isBrowserstackSession)(this._browser), this._accessibility);
|
|
80
83
|
};
|
|
84
|
+
this._browser.performScan = async () => {
|
|
85
|
+
return await (0, util_1.performA11yScan)(this._browser, (0, util_1.isBrowserstackSession)(this._browser), this._accessibility);
|
|
86
|
+
};
|
|
87
|
+
if (!this._accessibility) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!('overwriteCommand' in this._browser && Array.isArray(accessibility_scripts_1.default.commandsToWrap))) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
accessibility_scripts_1.default.commandsToWrap
|
|
94
|
+
.filter((command) => (command.name && command.class))
|
|
95
|
+
.forEach((command) => {
|
|
96
|
+
var _a;
|
|
97
|
+
try {
|
|
98
|
+
(_a = this._browser) === null || _a === void 0 ? void 0 : _a.overwriteCommand(command.name, this.commandWrapper.bind(this, command), command.class === 'Element');
|
|
99
|
+
}
|
|
100
|
+
catch (er) {
|
|
101
|
+
log.debug(`Unable to overwrite command ${node_util_1.default.format(command)} ${node_util_1.default.format(er)}`);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
81
104
|
}
|
|
82
105
|
async beforeTest(suiteTitle, test) {
|
|
83
106
|
if (this._framework !== 'mocha' ||
|
|
@@ -86,17 +109,14 @@ class _AccessibilityHandler {
|
|
|
86
109
|
}
|
|
87
110
|
const shouldScanTest = (0, util_1.shouldScanTestForAccessibility)(suiteTitle, test.title, this._accessibilityOptions);
|
|
88
111
|
const testIdentifier = this.getIdentifier(test);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
112
|
+
if (this._sessionId) {
|
|
113
|
+
/* For case with multiple tests under one browser, before hook of 2nd test should change this map value */
|
|
114
|
+
AccessibilityHandler._a11yScanSessionMap[this._sessionId] = shouldScanTest;
|
|
92
115
|
}
|
|
93
116
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
await this.sendTestForceStopEvent(this._browser);
|
|
117
|
+
const isPageOpened = await this.checkIfPageOpened(this._browser, testIdentifier, shouldScanTest);
|
|
118
|
+
if (!isPageOpened) {
|
|
119
|
+
return;
|
|
100
120
|
}
|
|
101
121
|
this._testMetadata[testIdentifier].accessibilityScanStarted = shouldScanTest;
|
|
102
122
|
if (shouldScanTest) {
|
|
@@ -146,27 +166,24 @@ class _AccessibilityHandler {
|
|
|
146
166
|
* Cucumber Only
|
|
147
167
|
*/
|
|
148
168
|
async beforeScenario(world) {
|
|
149
|
-
if (!this.shouldRunTestHooks(this._browser, this._accessibility)) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
169
|
const pickleData = world.pickle;
|
|
153
170
|
const gherkinDocument = world.gherkinDocument;
|
|
154
171
|
const featureData = gherkinDocument.feature;
|
|
155
172
|
const uniqueId = (0, util_1.getUniqueIdentifierForCucumber)(world);
|
|
156
|
-
|
|
157
|
-
const isPageOpened = await this.checkIfPageOpened(this._browser, uniqueId, shouldScanScenario);
|
|
158
|
-
if (!isPageOpened) {
|
|
173
|
+
if (!this.shouldRunTestHooks(this._browser, this._accessibility)) {
|
|
159
174
|
return;
|
|
160
175
|
}
|
|
161
176
|
try {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
177
|
+
const shouldScanScenario = (0, util_1.shouldScanTestForAccessibility)(featureData === null || featureData === void 0 ? void 0 : featureData.name, pickleData.name, this._accessibilityOptions);
|
|
178
|
+
const isPageOpened = await this.checkIfPageOpened(this._browser, uniqueId, shouldScanScenario);
|
|
179
|
+
this._testMetadata[uniqueId].accessibilityScanStarted = shouldScanScenario;
|
|
180
|
+
if (this._sessionId) {
|
|
181
|
+
/* For case with multiple tests under one browser, before hook of 2nd test should change this map value */
|
|
182
|
+
AccessibilityHandler._a11yScanSessionMap[this._sessionId] = shouldScanScenario;
|
|
165
183
|
}
|
|
166
|
-
|
|
167
|
-
|
|
184
|
+
if (!isPageOpened) {
|
|
185
|
+
return;
|
|
168
186
|
}
|
|
169
|
-
this._testMetadata[uniqueId].accessibilityScanStarted = shouldScanScenario;
|
|
170
187
|
if (shouldScanScenario) {
|
|
171
188
|
log.info('Automate test case execution has started.');
|
|
172
189
|
}
|
|
@@ -215,14 +232,20 @@ class _AccessibilityHandler {
|
|
|
215
232
|
/*
|
|
216
233
|
* private methods
|
|
217
234
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
235
|
+
async commandWrapper(command, origFunction, ...args) {
|
|
236
|
+
if (this._sessionId && AccessibilityHandler._a11yScanSessionMap[this._sessionId] &&
|
|
237
|
+
(!command.name.includes('execute') ||
|
|
238
|
+
!AccessibilityHandler.shouldPatchExecuteScript(args.length ? args[0] : null))) {
|
|
239
|
+
log.debug(`Performing scan for ${command.class} ${command.name}`);
|
|
240
|
+
await (0, util_1.performA11yScan)(this._browser, true, true, command.name);
|
|
241
|
+
}
|
|
242
|
+
return origFunction(...args);
|
|
223
243
|
}
|
|
224
|
-
sendTestStopEvent(browser, dataForExtension) {
|
|
225
|
-
|
|
244
|
+
async sendTestStopEvent(browser, dataForExtension) {
|
|
245
|
+
log.debug('Performing scan before saving results');
|
|
246
|
+
await (0, util_1.performA11yScan)(browser, true, true);
|
|
247
|
+
const results = await browser.executeAsync(accessibility_scripts_1.default.saveTestResults, dataForExtension);
|
|
248
|
+
log.debug(node_util_1.default.format(results));
|
|
226
249
|
}
|
|
227
250
|
getIdentifier(test) {
|
|
228
251
|
if ('pickle' in test) {
|
|
@@ -252,7 +275,15 @@ class _AccessibilityHandler {
|
|
|
252
275
|
}
|
|
253
276
|
return pageOpen;
|
|
254
277
|
}
|
|
278
|
+
static shouldPatchExecuteScript(script) {
|
|
279
|
+
if (!script || typeof script !== 'string') {
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
return (script.toLowerCase().indexOf('browserstack_executor') !== -1 ||
|
|
283
|
+
script.toLowerCase().indexOf('browserstack_accessibility_automation_script') !== -1);
|
|
284
|
+
}
|
|
255
285
|
}
|
|
286
|
+
_AccessibilityHandler._a11yScanSessionMap = {};
|
|
256
287
|
// https://github.com/microsoft/TypeScript/issues/6543
|
|
257
288
|
const AccessibilityHandler = (0, util_1.o11yClassErrorHandler)(_AccessibilityHandler);
|
|
258
289
|
exports.default = AccessibilityHandler;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class BStackLogger {
|
|
2
|
+
static logFilePath: string;
|
|
3
|
+
static logFolderPath: string;
|
|
4
|
+
private static logFileStream;
|
|
5
|
+
static info(message: string): void;
|
|
6
|
+
static error(message: string): void;
|
|
7
|
+
static debug(message: string, param?: any): void;
|
|
8
|
+
static warn(message: string): void;
|
|
9
|
+
static trace(message: string): void;
|
|
10
|
+
static clearLogger(): void;
|
|
11
|
+
static clearLogFile(): void;
|
|
12
|
+
static ensureLogsFolder(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=bstackLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bstackLogger.d.ts","sourceRoot":"","sources":["../src/bstackLogger.ts"],"names":[],"mappings":"AASA,qBAAa,YAAY;IACrB,OAAc,WAAW,SAAsC;IAC/D,OAAc,aAAa,SAAmC;IAC9D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAuB;WAErC,IAAI,CAAC,OAAO,EAAE,MAAM;WAIpB,KAAK,CAAC,OAAO,EAAE,MAAM;WAIrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;WAQlC,IAAI,CAAC,OAAO,EAAE,MAAM;WAIpB,KAAK,CAAC,OAAO,EAAE,MAAM;WAIrB,WAAW;WAOX,YAAY;WAMZ,gBAAgB;CAKjC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BStackLogger = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
const log = (0, logger_1.default)('@wdio/browserstack-service');
|
|
12
|
+
class BStackLogger {
|
|
13
|
+
static info(message) {
|
|
14
|
+
log.info(message);
|
|
15
|
+
}
|
|
16
|
+
static error(message) {
|
|
17
|
+
log.error(message);
|
|
18
|
+
}
|
|
19
|
+
static debug(message, param) {
|
|
20
|
+
if (param) {
|
|
21
|
+
log.debug(message, param);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
log.debug(message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
static warn(message) {
|
|
28
|
+
log.warn(message);
|
|
29
|
+
}
|
|
30
|
+
static trace(message) {
|
|
31
|
+
log.trace(message);
|
|
32
|
+
}
|
|
33
|
+
static clearLogger() {
|
|
34
|
+
if (this.logFileStream) {
|
|
35
|
+
this.logFileStream.end();
|
|
36
|
+
}
|
|
37
|
+
this.logFileStream = null;
|
|
38
|
+
}
|
|
39
|
+
static clearLogFile() {
|
|
40
|
+
if (node_fs_1.default.existsSync(this.logFilePath)) {
|
|
41
|
+
node_fs_1.default.truncateSync(this.logFilePath);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
static ensureLogsFolder() {
|
|
45
|
+
if (!node_fs_1.default.existsSync(this.logFolderPath)) {
|
|
46
|
+
node_fs_1.default.mkdirSync(this.logFolderPath);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.BStackLogger = BStackLogger;
|
|
51
|
+
BStackLogger.logFilePath = node_path_1.default.join(process.cwd(), constants_1.LOGS_FILE);
|
|
52
|
+
BStackLogger.logFolderPath = node_path_1.default.join(process.cwd(), 'logs');
|
package/build/cleanup.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export default class BStackCleanup {
|
|
2
|
-
static startCleanup(): void
|
|
3
|
-
static executeObservabilityCleanup(): void
|
|
2
|
+
static startCleanup(): Promise<void>;
|
|
3
|
+
static executeObservabilityCleanup(funnelData: any): Promise<void>;
|
|
4
|
+
static updateO11yStopData(funnelData: any, status: string, error?: unknown): void;
|
|
5
|
+
static sendFunnelData(funnelData: any): Promise<void>;
|
|
6
|
+
static removeFunnelDataFile(filePath?: string): void;
|
|
7
|
+
static getFunnelDataFromFile(filePath: string): any;
|
|
4
8
|
}
|
|
5
9
|
//# sourceMappingURL=cleanup.d.ts.map
|
package/build/cleanup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../src/cleanup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../src/cleanup.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,OAAO,aAAa;WACjB,YAAY;WAmBZ,2BAA2B,CAAC,UAAU,EAAE,GAAG;IAsBxD,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,OAAmB;WAkBxE,cAAc,CAAC,UAAU,EAAE,GAAG;IAS3C,MAAM,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM;IAO7C,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,MAAM;CAWhD"}
|
package/build/cleanup.js
CHANGED
|
@@ -1,23 +1,115 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
29
|
const util_1 = require("./util");
|
|
30
|
+
const fs_1 = __importDefault(require("fs"));
|
|
31
|
+
const bstackLogger_1 = require("./bstackLogger");
|
|
32
|
+
const funnelInstrumentation_1 = require("./instrumentation/funnelInstrumentation");
|
|
33
|
+
const constants_1 = require("./constants");
|
|
34
|
+
const process = __importStar(require("process"));
|
|
4
35
|
class BStackCleanup {
|
|
5
|
-
static startCleanup() {
|
|
6
|
-
|
|
36
|
+
static async startCleanup() {
|
|
37
|
+
// Get funnel data object from saved file
|
|
38
|
+
const funnelDataCleanup = process.argv.includes('--funnelData');
|
|
39
|
+
let funnelData = null;
|
|
40
|
+
if (funnelDataCleanup) {
|
|
41
|
+
const index = process.argv.indexOf('--funnelData');
|
|
42
|
+
const filePath = process.argv[index + 1];
|
|
43
|
+
funnelData = this.getFunnelDataFromFile(filePath);
|
|
44
|
+
}
|
|
45
|
+
if (process.argv.includes('--observability')) {
|
|
46
|
+
await this.executeObservabilityCleanup(funnelData);
|
|
47
|
+
}
|
|
48
|
+
if (funnelDataCleanup && funnelData) {
|
|
49
|
+
await this.sendFunnelData(funnelData);
|
|
50
|
+
}
|
|
7
51
|
}
|
|
8
|
-
static executeObservabilityCleanup() {
|
|
9
|
-
if (!process.env.
|
|
52
|
+
static async executeObservabilityCleanup(funnelData) {
|
|
53
|
+
if (!process.env[constants_1.TESTOPS_JWT_ENV]) {
|
|
10
54
|
return;
|
|
11
55
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
56
|
+
bstackLogger_1.BStackLogger.debug('Executing observability cleanup');
|
|
57
|
+
try {
|
|
58
|
+
const result = await (0, util_1.stopBuildUpstream)();
|
|
59
|
+
if (process.env[constants_1.TESTOPS_BUILD_ID_ENV]) {
|
|
60
|
+
bstackLogger_1.BStackLogger.info(`\nVisit https://observability.browserstack.com/builds/${process.env[constants_1.TESTOPS_BUILD_ID_ENV]} to view build report, insights, and many more debugging information all at one place!\n`);
|
|
16
61
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
62
|
+
const status = (result && result.status) || 'failed';
|
|
63
|
+
const message = (result && result.message);
|
|
64
|
+
this.updateO11yStopData(funnelData, status, status === 'failed' ? message : undefined);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
bstackLogger_1.BStackLogger.error('Error in stopping Observability build: ' + e);
|
|
68
|
+
this.updateO11yStopData(funnelData, 'failed', e);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
static updateO11yStopData(funnelData, status, error = undefined) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
const toData = (_b = (_a = funnelData === null || funnelData === void 0 ? void 0 : funnelData.event_properties) === null || _a === void 0 ? void 0 : _a.productUsage) === null || _b === void 0 ? void 0 : _b.testObservability;
|
|
74
|
+
// Return if no O11y data in funnel data
|
|
75
|
+
if (!toData) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let existingStopData = toData.events.buildEvents.finished;
|
|
79
|
+
existingStopData = existingStopData || {};
|
|
80
|
+
existingStopData = {
|
|
81
|
+
...existingStopData,
|
|
82
|
+
status,
|
|
83
|
+
error: (0, util_1.getErrorString)(error),
|
|
84
|
+
stoppedFrom: 'exitHook'
|
|
85
|
+
};
|
|
86
|
+
toData.events.buildEvents.finished = existingStopData;
|
|
87
|
+
}
|
|
88
|
+
static async sendFunnelData(funnelData) {
|
|
89
|
+
try {
|
|
90
|
+
await (0, funnelInstrumentation_1.fireFunnelRequest)(funnelData);
|
|
91
|
+
bstackLogger_1.BStackLogger.debug('Funnel data sent successfully from cleanup');
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
bstackLogger_1.BStackLogger.error('Error in sending funnel data: ' + e);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
static removeFunnelDataFile(filePath) {
|
|
98
|
+
if (!filePath) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
fs_1.default.rmSync(filePath, { force: true });
|
|
102
|
+
}
|
|
103
|
+
static getFunnelDataFromFile(filePath) {
|
|
104
|
+
if (!filePath) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
bstackLogger_1.BStackLogger.debug('Getting saved funnel data from file ' + filePath);
|
|
108
|
+
const content = fs_1.default.readFileSync(filePath, 'utf8');
|
|
109
|
+
const data = JSON.parse(content);
|
|
110
|
+
this.removeFunnelDataFile(filePath);
|
|
111
|
+
return data;
|
|
20
112
|
}
|
|
21
113
|
}
|
|
22
114
|
exports.default = BStackCleanup;
|
|
23
|
-
BStackCleanup.startCleanup();
|
|
115
|
+
(async () => await BStackCleanup.startCleanup())();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppConfig, BrowserstackConfig } from './types';
|
|
2
|
+
import type { Options } from '@wdio/types';
|
|
3
|
+
import TestOpsConfig from './testOps/testOpsConfig';
|
|
4
|
+
declare class BrowserStackConfig {
|
|
5
|
+
static getInstance(options?: BrowserstackConfig & Options.Testrunner, config?: Options.Testrunner): BrowserStackConfig;
|
|
6
|
+
userName?: string;
|
|
7
|
+
accessKey?: string;
|
|
8
|
+
framework?: string;
|
|
9
|
+
buildName?: string;
|
|
10
|
+
buildIdentifier?: string;
|
|
11
|
+
testObservability: TestOpsConfig;
|
|
12
|
+
percy: boolean;
|
|
13
|
+
accessibility: boolean;
|
|
14
|
+
app?: string | AppConfig;
|
|
15
|
+
private static _instance;
|
|
16
|
+
appAutomate: boolean;
|
|
17
|
+
automate: boolean;
|
|
18
|
+
funnelDataSent: boolean;
|
|
19
|
+
constructor(options: BrowserstackConfig & Options.Testrunner, config: Options.Testrunner);
|
|
20
|
+
sentFunnelData(): void;
|
|
21
|
+
}
|
|
22
|
+
export default BrowserStackConfig;
|
|
23
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,aAAa,MAAM,yBAAyB,CAAA;AAGnD,cAAM,kBAAkB;IACpB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,GAAG,kBAAkB;IAO/G,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,aAAa,CAAA;IAChC,KAAK,EAAE,OAAO,CAAA;IACd,aAAa,EAAE,OAAO,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,GAAC,SAAS,CAAA;IAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAoB;IACrC,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAQ;gBAE1B,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU;IAaxF,cAAc;CAIjB;AAED,eAAe,kBAAkB,CAAA"}
|
package/build/config.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const testOpsConfig_1 = __importDefault(require("./testOps/testOpsConfig"));
|
|
7
|
+
const util_1 = require("./util");
|
|
8
|
+
class BrowserStackConfig {
|
|
9
|
+
static getInstance(options, config) {
|
|
10
|
+
if (!this._instance && options && config) {
|
|
11
|
+
this._instance = new BrowserStackConfig(options, config);
|
|
12
|
+
}
|
|
13
|
+
return this._instance;
|
|
14
|
+
}
|
|
15
|
+
constructor(options, config) {
|
|
16
|
+
this.funnelDataSent = false;
|
|
17
|
+
this.framework = config.framework;
|
|
18
|
+
this.userName = config.user;
|
|
19
|
+
this.accessKey = config.key;
|
|
20
|
+
this.testObservability = new testOpsConfig_1.default(options.testObservability !== false, !(0, util_1.isUndefined)(options.testObservability));
|
|
21
|
+
this.percy = options.percy || false;
|
|
22
|
+
this.accessibility = options.accessibility || false;
|
|
23
|
+
this.app = options.app;
|
|
24
|
+
this.appAutomate = !(0, util_1.isUndefined)(options.app);
|
|
25
|
+
this.automate = !this.appAutomate;
|
|
26
|
+
this.buildIdentifier = options.buildIdentifier;
|
|
27
|
+
}
|
|
28
|
+
sentFunnelData() {
|
|
29
|
+
this.funnelDataSent = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = BrowserStackConfig;
|
package/build/constants.d.ts
CHANGED
|
@@ -12,9 +12,26 @@ export declare const DATA_BATCH_INTERVAL = 2000;
|
|
|
12
12
|
export declare const BATCH_EVENT_TYPES: string[];
|
|
13
13
|
export declare const DEFAULT_WAIT_TIMEOUT_FOR_PENDING_UPLOADS = 5000;
|
|
14
14
|
export declare const DEFAULT_WAIT_INTERVAL_FOR_PENDING_UPLOADS = 100;
|
|
15
|
+
export declare const BSTACK_SERVICE_VERSION: string;
|
|
15
16
|
export declare const ACCESSIBILITY_API_URL = "https://accessibility.browserstack.com/api";
|
|
16
17
|
export declare const NOT_ALLOWED_KEYS_IN_CAPS: string[];
|
|
18
|
+
export declare const LOGS_FILE = "logs/bstack-wdio-service.log";
|
|
19
|
+
export declare const COLORS: Record<string, string>;
|
|
17
20
|
export declare const PERCY_LOGS_FILE = "logs/percy.log";
|
|
18
21
|
export declare const PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS: string[];
|
|
19
22
|
export declare const CAPTURE_MODES: string[];
|
|
23
|
+
export declare const LOG_KIND_USAGE_MAP: {
|
|
24
|
+
TEST_LOG: string;
|
|
25
|
+
TEST_SCREENSHOT: string;
|
|
26
|
+
TEST_STEP: string;
|
|
27
|
+
HTTP: string;
|
|
28
|
+
};
|
|
29
|
+
export declare const FUNNEL_INSTRUMENTATION_URL = "https://api.browserstack.com/sdk/v1/event";
|
|
30
|
+
export declare const TESTOPS_JWT_ENV = "BS_TESTOPS_JWT";
|
|
31
|
+
export declare const TESTOPS_SCREENSHOT_ENV = "BS_TESTOPS_ALLOW_SCREENSHOTS";
|
|
32
|
+
export declare const TESTOPS_BUILD_ID_ENV = "BS_TESTOPS_BUILD_HASHED_ID";
|
|
33
|
+
export declare const PERF_MEASUREMENT_ENV = "BROWSERSTACK_O11Y_PERF_MEASUREMENT";
|
|
34
|
+
export declare const RERUN_TESTS_ENV = "BROWSERSTACK_RERUN_TESTS";
|
|
35
|
+
export declare const RERUN_ENV = "BROWSERSTACK_RERUN";
|
|
36
|
+
export declare const TESTOPS_BUILD_COMPLETED_ENV = "BS_TESTOPS_BUILD_COMPLETED";
|
|
20
37
|
//# sourceMappingURL=constants.d.ts.map
|
package/build/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAGjD,eAAO,MAAM,mBAAmB,qHAStB,CAAA;AAEV,eAAO,MAAM,mBAAmB,UAI/B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,kBAAkB,CAKvD,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,OAAO,OAAoC,CAAA;AACvE,eAAO,MAAM,aAAa,qDAAqD,CAAA;AAC/E,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AACjD,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AACjD,eAAO,MAAM,wBAAwB,uBAAuB,CAAA;AAC5D,eAAO,MAAM,eAAe,OAAO,CAAA;AACnC,eAAO,MAAM,mBAAmB,OAAO,CAAA;AACvC,eAAO,MAAM,iBAAiB,UAAgH,CAAA;AAC9I,eAAO,MAAM,wCAAwC,OAAO,CAAA;AAC5D,eAAO,MAAM,yCAAyC,MAAM,CAAA;AAE5D,eAAO,MAAM,sBAAsB,QAAuB,CAAA;AAE1D,eAAO,MAAM,qBAAqB,+CAA+C,CAAA;AACjF,eAAO,MAAM,wBAAwB,UAA6D,CAAA;AAElG,eAAO,MAAM,SAAS,iCAAiC,CAAA;AACvD,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOzC,CAAA;AAED,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,eAAO,MAAM,qCAAqC,UAQjD,CAAA;AAED,eAAO,MAAM,aAAa,UAAwD,CAAA;AAElF,eAAO,MAAM,kBAAkB;;;;;CAK9B,CAAA;AAED,eAAO,MAAM,0BAA0B,8CAA8C,CAAA;AAKrF,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAG/C,eAAO,MAAM,sBAAsB,iCAAiC,CAAA;AAGpE,eAAO,MAAM,oBAAoB,+BAA+B,CAAA;AAGhE,eAAO,MAAM,oBAAoB,uCAAuC,CAAA;AAGxE,eAAO,MAAM,eAAe,6BAA6B,CAAA;AAGzD,eAAO,MAAM,SAAS,uBAAuB,CAAA;AAG7C,eAAO,MAAM,2BAA2B,+BAA+B,CAAA"}
|
package/build/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CAPTURE_MODES = exports.PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS = exports.PERCY_LOGS_FILE = exports.NOT_ALLOWED_KEYS_IN_CAPS = exports.ACCESSIBILITY_API_URL = exports.DEFAULT_WAIT_INTERVAL_FOR_PENDING_UPLOADS = exports.DEFAULT_WAIT_TIMEOUT_FOR_PENDING_UPLOADS = exports.BATCH_EVENT_TYPES = exports.DATA_BATCH_INTERVAL = exports.DATA_BATCH_SIZE = exports.DATA_SCREENSHOT_ENDPOINT = exports.DATA_BATCH_ENDPOINT = exports.DATA_EVENT_ENDPOINT = exports.DATA_ENDPOINT = exports.consoleHolder = exports.DEFAULT_OPTIONS = exports.VALID_APP_EXTENSION = exports.BROWSER_DESCRIPTION = void 0;
|
|
3
|
+
exports.TESTOPS_BUILD_COMPLETED_ENV = exports.RERUN_ENV = exports.RERUN_TESTS_ENV = exports.PERF_MEASUREMENT_ENV = exports.TESTOPS_BUILD_ID_ENV = exports.TESTOPS_SCREENSHOT_ENV = exports.TESTOPS_JWT_ENV = exports.FUNNEL_INSTRUMENTATION_URL = exports.LOG_KIND_USAGE_MAP = exports.CAPTURE_MODES = exports.PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS = exports.PERCY_LOGS_FILE = exports.COLORS = exports.LOGS_FILE = exports.NOT_ALLOWED_KEYS_IN_CAPS = exports.ACCESSIBILITY_API_URL = exports.BSTACK_SERVICE_VERSION = exports.DEFAULT_WAIT_INTERVAL_FOR_PENDING_UPLOADS = exports.DEFAULT_WAIT_TIMEOUT_FOR_PENDING_UPLOADS = exports.BATCH_EVENT_TYPES = exports.DATA_BATCH_INTERVAL = exports.DATA_BATCH_SIZE = exports.DATA_SCREENSHOT_ENDPOINT = exports.DATA_BATCH_ENDPOINT = exports.DATA_EVENT_ENDPOINT = exports.DATA_ENDPOINT = exports.consoleHolder = exports.DEFAULT_OPTIONS = exports.VALID_APP_EXTENSION = exports.BROWSER_DESCRIPTION = void 0;
|
|
4
|
+
const package_json_1 = require("../package.json");
|
|
4
5
|
exports.BROWSER_DESCRIPTION = [
|
|
5
6
|
'device',
|
|
6
7
|
'os',
|
|
@@ -32,8 +33,18 @@ exports.DATA_BATCH_INTERVAL = 2000;
|
|
|
32
33
|
exports.BATCH_EVENT_TYPES = ['LogCreated', 'TestRunStarted', 'TestRunFinished', 'HookRunFinished', 'HookRunStarted', 'ScreenshotCreated'];
|
|
33
34
|
exports.DEFAULT_WAIT_TIMEOUT_FOR_PENDING_UPLOADS = 5000; // 5s
|
|
34
35
|
exports.DEFAULT_WAIT_INTERVAL_FOR_PENDING_UPLOADS = 100; // 100ms
|
|
36
|
+
exports.BSTACK_SERVICE_VERSION = package_json_1.version;
|
|
35
37
|
exports.ACCESSIBILITY_API_URL = 'https://accessibility.browserstack.com/api';
|
|
36
38
|
exports.NOT_ALLOWED_KEYS_IN_CAPS = ['includeTagsInTestingScope', 'excludeTagsInTestingScope'];
|
|
39
|
+
exports.LOGS_FILE = 'logs/bstack-wdio-service.log';
|
|
40
|
+
exports.COLORS = {
|
|
41
|
+
error: 'red',
|
|
42
|
+
warn: 'yellow',
|
|
43
|
+
info: 'cyanBright',
|
|
44
|
+
debug: 'green',
|
|
45
|
+
trace: 'cyan',
|
|
46
|
+
progress: 'magenta'
|
|
47
|
+
};
|
|
37
48
|
exports.PERCY_LOGS_FILE = 'logs/percy.log';
|
|
38
49
|
exports.PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS = [
|
|
39
50
|
'/session/:sessionId/url',
|
|
@@ -45,3 +56,25 @@ exports.PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS = [
|
|
|
45
56
|
'/session/:sessionId/appium/device/shake'
|
|
46
57
|
];
|
|
47
58
|
exports.CAPTURE_MODES = ['click', 'auto', 'screenshot', 'manual', 'testcase'];
|
|
59
|
+
exports.LOG_KIND_USAGE_MAP = {
|
|
60
|
+
'TEST_LOG': 'log',
|
|
61
|
+
'TEST_SCREENSHOT': 'screenshot',
|
|
62
|
+
'TEST_STEP': 'step',
|
|
63
|
+
'HTTP': 'http'
|
|
64
|
+
};
|
|
65
|
+
exports.FUNNEL_INSTRUMENTATION_URL = 'https://api.browserstack.com/sdk/v1/event';
|
|
66
|
+
// Env variables - Define all the env variable constants over here
|
|
67
|
+
// To store the JWT token returned the session launch
|
|
68
|
+
exports.TESTOPS_JWT_ENV = 'BS_TESTOPS_JWT';
|
|
69
|
+
// To store the setting of whether to send screenshots or not
|
|
70
|
+
exports.TESTOPS_SCREENSHOT_ENV = 'BS_TESTOPS_ALLOW_SCREENSHOTS';
|
|
71
|
+
// To store build hashed id
|
|
72
|
+
exports.TESTOPS_BUILD_ID_ENV = 'BS_TESTOPS_BUILD_HASHED_ID';
|
|
73
|
+
// Whether to collect performance instrumentation or not
|
|
74
|
+
exports.PERF_MEASUREMENT_ENV = 'BROWSERSTACK_O11Y_PERF_MEASUREMENT';
|
|
75
|
+
// Whether the current run is rerun or not
|
|
76
|
+
exports.RERUN_TESTS_ENV = 'BROWSERSTACK_RERUN_TESTS';
|
|
77
|
+
// The tests that needs to be rerun
|
|
78
|
+
exports.RERUN_ENV = 'BROWSERSTACK_RERUN';
|
|
79
|
+
// To store whether the build launch has completed or not
|
|
80
|
+
exports.TESTOPS_BUILD_COMPLETED_ENV = 'BS_TESTOPS_BUILD_COMPLETED';
|
package/build/crash-reporter.js
CHANGED
|
@@ -55,7 +55,7 @@ class CrashReporter {
|
|
|
55
55
|
this.userConfigForReporting = {};
|
|
56
56
|
}
|
|
57
57
|
const data = {
|
|
58
|
-
hashed_id: process.env.
|
|
58
|
+
hashed_id: process.env[constants_1.TESTOPS_BUILD_ID_ENV],
|
|
59
59
|
observability_version: {
|
|
60
60
|
frameworkName: 'WebdriverIO-' + (this.userConfigForReporting.framework || 'null'),
|
|
61
61
|
sdkVersion: package_json_1.version
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-store.d.ts","sourceRoot":"","sources":["../src/data-store.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,6BAoBjC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QASvD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.saveWorkerData = exports.getDataFromWorkers = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const bstackLogger_1 = require("./bstackLogger");
|
|
10
|
+
const workersDataDirPath = node_path_1.default.join(process.cwd(), 'logs', 'worker_data');
|
|
11
|
+
function getDataFromWorkers() {
|
|
12
|
+
const workersData = [];
|
|
13
|
+
if (!node_fs_1.default.existsSync(workersDataDirPath)) {
|
|
14
|
+
return workersData;
|
|
15
|
+
}
|
|
16
|
+
const files = node_fs_1.default.readdirSync(workersDataDirPath);
|
|
17
|
+
files.forEach((file) => {
|
|
18
|
+
bstackLogger_1.BStackLogger.debug('Reading worker file ' + file);
|
|
19
|
+
const filePath = node_path_1.default.join(workersDataDirPath, file);
|
|
20
|
+
const fileContent = node_fs_1.default.readFileSync(filePath, 'utf8');
|
|
21
|
+
const workerData = JSON.parse(fileContent);
|
|
22
|
+
workersData.push(workerData);
|
|
23
|
+
});
|
|
24
|
+
// Remove worker data after all reading
|
|
25
|
+
removeWorkersDataDir();
|
|
26
|
+
return workersData;
|
|
27
|
+
}
|
|
28
|
+
exports.getDataFromWorkers = getDataFromWorkers;
|
|
29
|
+
function saveWorkerData(data) {
|
|
30
|
+
const filePath = node_path_1.default.join(workersDataDirPath, 'worker-data-' + process.pid + '.json');
|
|
31
|
+
try {
|
|
32
|
+
createWorkersDataDir();
|
|
33
|
+
node_fs_1.default.writeFileSync(filePath, JSON.stringify(data));
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
bstackLogger_1.BStackLogger.debug('Exception in saving worker data: ' + e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.saveWorkerData = saveWorkerData;
|
|
40
|
+
function removeWorkersDataDir() {
|
|
41
|
+
node_fs_1.default.rmSync(workersDataDirPath, { recursive: true, force: true });
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
function createWorkersDataDir() {
|
|
45
|
+
if (!node_fs_1.default.existsSync(workersDataDirPath)) {
|
|
46
|
+
node_fs_1.default.mkdirSync(workersDataDirPath, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|