@wdio/browserstack-service 7.32.4 → 7.34.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 +39 -0
- package/build/accessibility-handler.d.ts.map +1 -0
- package/build/accessibility-handler.js +258 -0
- package/build/cleanup.d.ts +5 -0
- package/build/cleanup.d.ts.map +1 -0
- package/build/cleanup.js +23 -0
- package/build/constants.d.ts +3 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +6 -2
- package/build/cucumber-types.d.ts +17 -0
- package/build/cucumber-types.d.ts.map +1 -1
- package/build/index.d.ts +5 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -1
- package/build/insights-handler.d.ts +19 -3
- package/build/insights-handler.d.ts.map +1 -1
- package/build/insights-handler.js +275 -17
- package/build/launcher.d.ts +6 -0
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +164 -0
- package/build/log4jsAppender.d.ts +2 -0
- package/build/log4jsAppender.d.ts.map +1 -0
- package/build/log4jsAppender.js +26 -0
- package/build/logPatcher.d.ts +13 -0
- package/build/logPatcher.d.ts.map +1 -0
- package/build/logPatcher.js +43 -0
- package/build/logReportingAPI.d.ts +12 -0
- package/build/logReportingAPI.d.ts.map +1 -0
- package/build/logReportingAPI.js +61 -0
- package/build/reporter.d.ts +6 -1
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +42 -1
- package/build/request-handler.d.ts +1 -0
- package/build/request-handler.d.ts.map +1 -1
- package/build/request-handler.js +5 -0
- package/build/scripts/test-event-scripts.d.ts +10 -0
- package/build/scripts/test-event-scripts.d.ts.map +1 -0
- package/build/scripts/test-event-scripts.js +73 -0
- package/build/service.d.ts +6 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +50 -7
- package/build/types.d.ts +43 -1
- package/build/types.d.ts.map +1 -1
- package/build/util.d.ts +48 -1
- package/build/util.d.ts.map +1 -1
- package/build/util.js +448 -11
- package/package.json +6 -5
package/build/launcher.js
CHANGED
|
@@ -36,6 +36,7 @@ const os_1 = __importDefault(require("os"));
|
|
|
36
36
|
const webdriverio_1 = require("webdriverio");
|
|
37
37
|
const BrowserstackLocalLauncher = __importStar(require("browserstack-local"));
|
|
38
38
|
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
39
|
+
const node_child_process_1 = require("node:child_process");
|
|
39
40
|
// @ts-ignore
|
|
40
41
|
const package_json_1 = require("../package.json");
|
|
41
42
|
const crash_reporter_1 = __importDefault(require("./crash-reporter"));
|
|
@@ -48,6 +49,7 @@ class BrowserstackLauncherService {
|
|
|
48
49
|
this._options = _options;
|
|
49
50
|
this._config = _config;
|
|
50
51
|
// added to maintain backward compatibility with webdriverIO v5
|
|
52
|
+
this.setupExitHandlers();
|
|
51
53
|
this._config || (this._config = _options);
|
|
52
54
|
if (Array.isArray(capabilities)) {
|
|
53
55
|
capabilities.forEach((capability) => {
|
|
@@ -57,6 +59,12 @@ class BrowserstackLauncherService {
|
|
|
57
59
|
const extensionCaps = Object.keys(capability).filter((cap) => cap.includes(':'));
|
|
58
60
|
if (extensionCaps.length) {
|
|
59
61
|
capability['bstack:options'] = { wdioService: package_json_1.version };
|
|
62
|
+
if (!(0, util_2.isUndefined)(capability['browserstack.accessibility'])) {
|
|
63
|
+
this._accessibilityAutomation || (this._accessibilityAutomation = (0, util_2.isTrue)(capability['browserstack.accessibility']));
|
|
64
|
+
}
|
|
65
|
+
else if ((0, util_2.isTrue)(this._options.accessibility)) {
|
|
66
|
+
capability['bstack:options'].accessibility = true;
|
|
67
|
+
}
|
|
60
68
|
}
|
|
61
69
|
else if ((0, util_2.shouldAddServiceVersion)(this._config, this._options.testObservability)) {
|
|
62
70
|
capability['browserstack.wdioService'] = package_json_1.version;
|
|
@@ -71,6 +79,12 @@ class BrowserstackLauncherService {
|
|
|
71
79
|
this._projectName = capability['bstack:options'].projectName;
|
|
72
80
|
this._buildTag = capability['bstack:options'].buildTag;
|
|
73
81
|
this._buildIdentifier = capability['bstack:options'].buildIdentifier;
|
|
82
|
+
if (!(0, util_2.isUndefined)(capability['bstack:options'].accessibility)) {
|
|
83
|
+
this._accessibilityAutomation || (this._accessibilityAutomation = (0, util_2.isTrue)(capability['bstack:options'].accessibility));
|
|
84
|
+
}
|
|
85
|
+
else if ((0, util_2.isTrue)(this._options.accessibility)) {
|
|
86
|
+
capability['bstack:options'].accessibility = ((0, util_2.isTrue)(this._options.accessibility));
|
|
87
|
+
}
|
|
74
88
|
}
|
|
75
89
|
});
|
|
76
90
|
}
|
|
@@ -81,6 +95,12 @@ class BrowserstackLauncherService {
|
|
|
81
95
|
const extensionCaps = Object.keys(caps.capabilities).filter((cap) => cap.includes(':'));
|
|
82
96
|
if (extensionCaps.length) {
|
|
83
97
|
caps.capabilities['bstack:options'] = { wdioService: package_json_1.version };
|
|
98
|
+
if (!(0, util_2.isUndefined)(caps.capabilities['browserstack.accessibility'])) {
|
|
99
|
+
this._accessibilityAutomation || (this._accessibilityAutomation = (0, util_2.isTrue)(caps.capabilities['browserstack.accessibility']));
|
|
100
|
+
}
|
|
101
|
+
else if ((0, util_2.isTrue)(this._options.accessibility)) {
|
|
102
|
+
caps.capabilities['bstack:options'] = { wdioService: package_json_1.version, accessibility: ((0, util_2.isTrue)(this._options.accessibility)) };
|
|
103
|
+
}
|
|
84
104
|
}
|
|
85
105
|
else if ((0, util_2.shouldAddServiceVersion)(this._config, this._options.testObservability)) {
|
|
86
106
|
caps.capabilities['browserstack.wdioService'] = package_json_1.version;
|
|
@@ -95,12 +115,20 @@ class BrowserstackLauncherService {
|
|
|
95
115
|
this._projectName = bstackOptions.projectName;
|
|
96
116
|
this._buildTag = bstackOptions.buildTag;
|
|
97
117
|
this._buildIdentifier = bstackOptions.buildIdentifier;
|
|
118
|
+
if (!(0, util_2.isUndefined)(bstackOptions.accessibility)) {
|
|
119
|
+
this._accessibilityAutomation || (this._accessibilityAutomation = (0, util_2.isTrue)(bstackOptions.accessibility));
|
|
120
|
+
}
|
|
121
|
+
else if ((0, util_2.isTrue)(this._options.accessibility)) {
|
|
122
|
+
bstackOptions.accessibility = (0, util_2.isTrue)(this._options.accessibility);
|
|
123
|
+
}
|
|
98
124
|
}
|
|
99
125
|
});
|
|
100
126
|
}
|
|
101
127
|
if (process.env.BROWSERSTACK_O11Y_PERF_MEASUREMENT) {
|
|
102
128
|
performance_tester_1.default.startMonitoring('performance-report-launcher.csv');
|
|
103
129
|
}
|
|
130
|
+
this._accessibilityAutomation || (this._accessibilityAutomation = (0, util_2.isTrue)(this._options.accessibility));
|
|
131
|
+
this._options.accessibility = this._accessibilityAutomation;
|
|
104
132
|
// by default observability will be true unless specified as false
|
|
105
133
|
this._options.testObservability = this._options.testObservability == false ? false : true;
|
|
106
134
|
if (this._options.testObservability &&
|
|
@@ -115,6 +143,15 @@ class BrowserstackLauncherService {
|
|
|
115
143
|
log.error(`[Crash_Report_Upload] Config processing failed due to ${error}`);
|
|
116
144
|
}
|
|
117
145
|
}
|
|
146
|
+
setupExitHandlers() {
|
|
147
|
+
process.on('exit', (code) => {
|
|
148
|
+
if (!!process.env.BS_TESTOPS_JWT && !this._testOpsBuildStopped) {
|
|
149
|
+
const childProcess = (0, node_child_process_1.spawn)('node', [`${path_1.default.join(__dirname, 'cleanup.js')}`], { detached: true, stdio: 'inherit', env: { ...process.env } });
|
|
150
|
+
childProcess.unref();
|
|
151
|
+
process.exit(code);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
118
155
|
async onPrepare(config, capabilities) {
|
|
119
156
|
/**
|
|
120
157
|
* Upload app to BrowserStack if valid file path to app is given.
|
|
@@ -161,6 +198,37 @@ class BrowserstackLauncherService {
|
|
|
161
198
|
* e.g., ${BUILD_NUMBER} and ${DATE_TIME}
|
|
162
199
|
*/
|
|
163
200
|
this._handleBuildIdentifier(capabilities);
|
|
201
|
+
// remove accessibilityOptions from the capabilities if present
|
|
202
|
+
this._updateObjectTypeCaps(capabilities, 'accessibilityOptions');
|
|
203
|
+
if (this._accessibilityAutomation) {
|
|
204
|
+
const scannerVersion = await (0, util_2.createAccessibilityTestRun)(this._options, this._config, {
|
|
205
|
+
projectName: this._projectName,
|
|
206
|
+
buildName: this._buildName,
|
|
207
|
+
buildTag: this._buildTag,
|
|
208
|
+
bstackServiceVersion: package_json_1.version,
|
|
209
|
+
buildIdentifier: this._buildIdentifier,
|
|
210
|
+
accessibilityOptions: this._options.accessibilityOptions
|
|
211
|
+
});
|
|
212
|
+
if (scannerVersion) {
|
|
213
|
+
process.env.BSTACK_A11Y_SCANNER_VERSION = scannerVersion;
|
|
214
|
+
}
|
|
215
|
+
log.debug(`Accessibility scannerVersion ${scannerVersion}`);
|
|
216
|
+
}
|
|
217
|
+
if (this._options.accessibilityOptions) {
|
|
218
|
+
const filteredOpts = Object.keys(this._options.accessibilityOptions)
|
|
219
|
+
.filter(key => !constants_1.NOT_ALLOWED_KEYS_IN_CAPS.includes(key))
|
|
220
|
+
.reduce((opts, key) => {
|
|
221
|
+
var _a;
|
|
222
|
+
return {
|
|
223
|
+
...opts,
|
|
224
|
+
[key]: (_a = this._options.accessibilityOptions) === null || _a === void 0 ? void 0 : _a[key]
|
|
225
|
+
};
|
|
226
|
+
}, {});
|
|
227
|
+
this._updateObjectTypeCaps(capabilities, 'accessibilityOptions', filteredOpts);
|
|
228
|
+
}
|
|
229
|
+
else if ((0, util_2.isAccessibilityAutomationSession)(this._accessibilityAutomation)) {
|
|
230
|
+
this._updateObjectTypeCaps(capabilities, 'accessibilityOptions', {});
|
|
231
|
+
}
|
|
164
232
|
if (this._options.testObservability) {
|
|
165
233
|
log.debug('Sending launch start event');
|
|
166
234
|
await (0, util_2.launchTestSession)(this._options, this._config, {
|
|
@@ -212,11 +280,17 @@ class BrowserstackLauncherService {
|
|
|
212
280
|
});
|
|
213
281
|
}
|
|
214
282
|
async onComplete() {
|
|
283
|
+
if ((0, util_2.isAccessibilityAutomationSession)(this._accessibilityAutomation)) {
|
|
284
|
+
await (0, util_2.stopAccessibilityTestRun)().catch((error) => {
|
|
285
|
+
log.error(`Exception in stop accessibility test run: ${error}`);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
215
288
|
if (this._options.testObservability) {
|
|
216
289
|
log.debug('Sending stop launch event');
|
|
217
290
|
await (0, util_2.stopBuildUpstream)();
|
|
218
291
|
if (process.env.BS_TESTOPS_BUILD_HASHED_ID) {
|
|
219
292
|
console.log(`\nVisit https://observability.browserstack.com/builds/${process.env.BS_TESTOPS_BUILD_HASHED_ID} to view build report, insights, and many more debugging information all at one place!\n`);
|
|
293
|
+
this._testOpsBuildStopped = true;
|
|
220
294
|
}
|
|
221
295
|
}
|
|
222
296
|
if (process.env.BROWSERSTACK_O11Y_PERF_MEASUREMENT) {
|
|
@@ -299,6 +373,96 @@ class BrowserstackLauncherService {
|
|
|
299
373
|
}
|
|
300
374
|
return app;
|
|
301
375
|
}
|
|
376
|
+
_updateObjectTypeCaps(capabilities, capType, value) {
|
|
377
|
+
try {
|
|
378
|
+
if (Array.isArray(capabilities)) {
|
|
379
|
+
capabilities
|
|
380
|
+
.flatMap((c) => {
|
|
381
|
+
if (Object.values(c).length > 0 && Object.values(c).every(c => typeof c === 'object' && c.capabilities)) {
|
|
382
|
+
return Object.values(c).map((o) => o.capabilities);
|
|
383
|
+
}
|
|
384
|
+
return c;
|
|
385
|
+
})
|
|
386
|
+
.forEach((capability) => {
|
|
387
|
+
if (!capability['bstack:options']) {
|
|
388
|
+
const extensionCaps = Object.keys(capability).filter((cap) => cap.includes(':'));
|
|
389
|
+
if (extensionCaps.length) {
|
|
390
|
+
if (capType === 'accessibilityOptions' && value) {
|
|
391
|
+
capability['bstack:options'] = { accessibilityOptions: value };
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else if (capType === 'accessibilityOptions') {
|
|
395
|
+
if (value) {
|
|
396
|
+
const accessibilityOpts = { ...value };
|
|
397
|
+
if (capability === null || capability === void 0 ? void 0 : capability.accessibility) {
|
|
398
|
+
accessibilityOpts.authToken = process.env.BSTACK_A11Y_JWT;
|
|
399
|
+
accessibilityOpts.scannerVersion = process.env.BSTACK_A11Y_SCANNER_VERSION;
|
|
400
|
+
}
|
|
401
|
+
capability['browserstack.accessibilityOptions'] = accessibilityOpts;
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
delete capability['browserstack.accessibilityOptions'];
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
else if (capType === 'accessibilityOptions') {
|
|
409
|
+
if (value) {
|
|
410
|
+
const accessibilityOpts = { ...value };
|
|
411
|
+
if (capability['bstack:options'].accessibility) {
|
|
412
|
+
accessibilityOpts.authToken = process.env.BSTACK_A11Y_JWT;
|
|
413
|
+
accessibilityOpts.scannerVersion = process.env.BSTACK_A11Y_SCANNER_VERSION;
|
|
414
|
+
}
|
|
415
|
+
capability['bstack:options'].accessibilityOptions = accessibilityOpts;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
delete capability['bstack:options'].accessibilityOptions;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
else if (typeof capabilities === 'object') {
|
|
424
|
+
Object.entries(capabilities).forEach(([, caps]) => {
|
|
425
|
+
if (!caps.capabilities['bstack:options']) {
|
|
426
|
+
const extensionCaps = Object.keys(caps.capabilities).filter((cap) => cap.includes(':'));
|
|
427
|
+
if (extensionCaps.length) {
|
|
428
|
+
if (capType === 'accessibilityOptions' && value) {
|
|
429
|
+
caps.capabilities['bstack:options'] = { accessibilityOptions: value };
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else if (capType === 'accessibilityOptions') {
|
|
433
|
+
if (value) {
|
|
434
|
+
const accessibilityOpts = { ...value };
|
|
435
|
+
if (caps.capabilities['browserstack.accessibility']) {
|
|
436
|
+
accessibilityOpts.authToken = process.env.BSTACK_A11Y_JWT;
|
|
437
|
+
accessibilityOpts.scannerVersion = process.env.BSTACK_A11Y_SCANNER_VERSION;
|
|
438
|
+
}
|
|
439
|
+
caps.capabilities['browserstack.accessibilityOptions'] = accessibilityOpts;
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
delete caps.capabilities['browserstack.accessibilityOptions'];
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
else if (capType === 'accessibilityOptions') {
|
|
447
|
+
if (value) {
|
|
448
|
+
const accessibilityOpts = { ...value };
|
|
449
|
+
if (caps.capabilities['bstack:options'].accessibility) {
|
|
450
|
+
accessibilityOpts.authToken = process.env.BSTACK_A11Y_JWT;
|
|
451
|
+
accessibilityOpts.scannerVersion = process.env.BSTACK_A11Y_SCANNER_VERSION;
|
|
452
|
+
}
|
|
453
|
+
caps.capabilities['bstack:options'].accessibilityOptions = accessibilityOpts;
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
delete caps.capabilities['bstack:options'].accessibilityOptions;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
catch (error) {
|
|
463
|
+
log.debug(`Exception while retrieving capability value. Error - ${error}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
302
466
|
_updateCaps(capabilities, capType, value) {
|
|
303
467
|
if (Array.isArray(capabilities)) {
|
|
304
468
|
capabilities.forEach((capability) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log4jsAppender.d.ts","sourceRoot":"","sources":["../src/log4jsAppender.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,SAAS,WAAY,GAAG,WAAW,GAAG,KAAG,QAMrD,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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.configure = void 0;
|
|
7
|
+
const logReportingAPI_js_1 = __importDefault(require("./logReportingAPI.js"));
|
|
8
|
+
const BSTestOpsLogger = new logReportingAPI_js_1.default({});
|
|
9
|
+
//Disabling eslint here as there params can be used later
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+
function BSTestOpsLog4JSAppender(layout, timezoneOffset) {
|
|
12
|
+
return (loggingEvent) => {
|
|
13
|
+
BSTestOpsLogger.log({
|
|
14
|
+
level: loggingEvent.level ? loggingEvent.level.levelStr : null,
|
|
15
|
+
message: loggingEvent.data ? loggingEvent.data.join(' ') : null
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const configure = (config, layouts) => {
|
|
20
|
+
let layout = layouts.colouredLayout;
|
|
21
|
+
if (config.layout) {
|
|
22
|
+
layout = layouts.layout(config.layout.type, config.layout);
|
|
23
|
+
}
|
|
24
|
+
return BSTestOpsLog4JSAppender(layout, config.timezoneOffset);
|
|
25
|
+
};
|
|
26
|
+
exports.configure = configure;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Transport from 'winston-transport';
|
|
2
|
+
declare class logPatcher extends Transport {
|
|
3
|
+
constructor(opts: any);
|
|
4
|
+
logToTestOps: (level?: string, message?: string[]) => void;
|
|
5
|
+
trace: (...message: any) => void;
|
|
6
|
+
debug: (...message: any) => void;
|
|
7
|
+
info: (...message: any) => void;
|
|
8
|
+
warn: (...message: any) => void;
|
|
9
|
+
error: (...message: any) => void;
|
|
10
|
+
log: (...message: any) => void;
|
|
11
|
+
}
|
|
12
|
+
export default logPatcher;
|
|
13
|
+
//# sourceMappingURL=logPatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logPatcher.d.ts","sourceRoot":"","sources":["../src/logPatcher.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAMzC,cAAM,UAAW,SAAQ,SAAS;gBAClB,IAAI,EAAE,GAAG;IAIrB,YAAY,+CAQX;IAGD,KAAK,eAAgB,GAAG,UAEvB;IAED,KAAK,eAAgB,GAAG,UAEvB;IAED,IAAI,eAAgB,GAAG,UAEtB;IAED,IAAI,eAAgB,GAAG,UAEtB;IAED,KAAK,eAAgB,GAAG,UAEvB;IAED,GAAG,eAAgB,GAAG,UAErB;CACJ;AACD,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 winston_transport_1 = __importDefault(require("winston-transport"));
|
|
7
|
+
const LOG_LEVELS = {
|
|
8
|
+
INFO: 'INFO', ERROR: 'ERROR', DEBUG: 'DEBUG', TRACE: 'TRACE', WARN: 'WARN',
|
|
9
|
+
};
|
|
10
|
+
class logPatcher extends winston_transport_1.default {
|
|
11
|
+
constructor(opts) {
|
|
12
|
+
super(opts);
|
|
13
|
+
this.logToTestOps = (level = LOG_LEVELS.INFO, message = ['']) => {
|
|
14
|
+
process.emit(`bs:addLog:${process.pid}`, {
|
|
15
|
+
timestamp: new Date().toISOString(),
|
|
16
|
+
level: level.toUpperCase(),
|
|
17
|
+
message: `"${message.join(', ')}"`,
|
|
18
|
+
kind: 'TEST_LOG',
|
|
19
|
+
http_response: {}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
/* Patching this would show user an extended trace on their cli */
|
|
23
|
+
this.trace = (...message) => {
|
|
24
|
+
this.logToTestOps(LOG_LEVELS.TRACE, message);
|
|
25
|
+
};
|
|
26
|
+
this.debug = (...message) => {
|
|
27
|
+
this.logToTestOps(LOG_LEVELS.DEBUG, message);
|
|
28
|
+
};
|
|
29
|
+
this.info = (...message) => {
|
|
30
|
+
this.logToTestOps(LOG_LEVELS.INFO, message);
|
|
31
|
+
};
|
|
32
|
+
this.warn = (...message) => {
|
|
33
|
+
this.logToTestOps(LOG_LEVELS.WARN, message);
|
|
34
|
+
};
|
|
35
|
+
this.error = (...message) => {
|
|
36
|
+
this.logToTestOps(LOG_LEVELS.ERROR, message);
|
|
37
|
+
};
|
|
38
|
+
this.log = (...message) => {
|
|
39
|
+
this.logToTestOps(LOG_LEVELS.INFO, message);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = logPatcher;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Transport = require('winston-transport');
|
|
2
|
+
declare class logReportingAPI extends Transport {
|
|
3
|
+
log(info: any, callback?: undefined | Function): void;
|
|
4
|
+
logToTestOps: (level?: string, message?: string, consoleLog?: boolean) => void;
|
|
5
|
+
trace: (message: any) => void;
|
|
6
|
+
debug: (message: any) => void;
|
|
7
|
+
info: (message: any) => void;
|
|
8
|
+
warn: (message: any) => void;
|
|
9
|
+
error: (message: any) => void;
|
|
10
|
+
}
|
|
11
|
+
export default logReportingAPI;
|
|
12
|
+
//# sourceMappingURL=logReportingAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logReportingAPI.d.ts","sourceRoot":"","sources":["../src/logReportingAPI.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,GAAG,QAAQ,mBAAmB,CAAC,CAAC;AAWhD,cAAM,eAAgB,SAAQ,SAAS;IACnC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAE,SAAS,GAAC,QAAoB;IAkBvD,YAAY,mEAWX;IAGD,KAAK,YAAa,GAAG,UAEpB;IAED,KAAK,YAAa,GAAG,UAEpB;IAED,IAAI,YAAa,GAAG,UAEnB;IAED,IAAI,YAAa,GAAG,UAEnB;IAED,KAAK,YAAa,GAAG,UAEpB;CACJ;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Transport = require("winston-transport");
|
|
4
|
+
const constants_js_1 = require("./constants.js");
|
|
5
|
+
const LOG_LEVELS = {
|
|
6
|
+
INFO: 'INFO',
|
|
7
|
+
ERROR: 'ERROR',
|
|
8
|
+
DEBUG: 'DEBUG',
|
|
9
|
+
TRACE: 'TRACE',
|
|
10
|
+
WARN: 'WARN',
|
|
11
|
+
};
|
|
12
|
+
class logReportingAPI extends Transport {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.logToTestOps = (level = LOG_LEVELS.INFO, message = '', consoleLog = true) => {
|
|
16
|
+
if (consoleLog) {
|
|
17
|
+
constants_js_1.consoleHolder[level.toLowerCase()](message);
|
|
18
|
+
}
|
|
19
|
+
process.emit(`bs:addLog:${process.pid}`, {
|
|
20
|
+
timestamp: new Date().toISOString(),
|
|
21
|
+
level: level.toUpperCase(),
|
|
22
|
+
message: message,
|
|
23
|
+
kind: 'TEST_LOG',
|
|
24
|
+
http_response: {}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
/* Patching this would show user an extended trace on their cli */
|
|
28
|
+
this.trace = (message) => {
|
|
29
|
+
this.logToTestOps(LOG_LEVELS.TRACE, message);
|
|
30
|
+
};
|
|
31
|
+
this.debug = (message) => {
|
|
32
|
+
this.logToTestOps(LOG_LEVELS.DEBUG, message);
|
|
33
|
+
};
|
|
34
|
+
this.info = (message) => {
|
|
35
|
+
this.logToTestOps(LOG_LEVELS.INFO, message);
|
|
36
|
+
};
|
|
37
|
+
this.warn = (message) => {
|
|
38
|
+
this.logToTestOps(LOG_LEVELS.WARN, message);
|
|
39
|
+
};
|
|
40
|
+
this.error = (message) => {
|
|
41
|
+
this.logToTestOps(LOG_LEVELS.ERROR, message);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
log(info, callback = undefined) {
|
|
45
|
+
setImmediate(() => {
|
|
46
|
+
this.emit('logged', info);
|
|
47
|
+
});
|
|
48
|
+
if (typeof (info) === 'object') {
|
|
49
|
+
/* From log appender */
|
|
50
|
+
this.logToTestOps(info.level || LOG_LEVELS.INFO, info.message, false);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
/* From default console */
|
|
54
|
+
this.logToTestOps(LOG_LEVELS.INFO, info);
|
|
55
|
+
}
|
|
56
|
+
if (callback && typeof callback === 'function') {
|
|
57
|
+
callback();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = logReportingAPI;
|
package/build/reporter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WDIOReporter, { SuiteStats, TestStats, RunnerStats, HookStats } from '@wdio/reporter';
|
|
2
|
-
import { TestMeta } from './types';
|
|
2
|
+
import type { CurrentRunInfo, StdLog, TestMeta } from './types';
|
|
3
3
|
declare class _TestReporter extends WDIOReporter {
|
|
4
4
|
private _capabilities;
|
|
5
5
|
private _config?;
|
|
@@ -11,7 +11,12 @@ declare class _TestReporter extends WDIOReporter {
|
|
|
11
11
|
private static _tests;
|
|
12
12
|
private _gitConfigPath?;
|
|
13
13
|
private _gitConfigured;
|
|
14
|
+
private _currentHook;
|
|
15
|
+
private _currentTest;
|
|
14
16
|
onRunnerStart(runnerStats: RunnerStats): Promise<void>;
|
|
17
|
+
registerListeners(): void;
|
|
18
|
+
appendTestItemLog(stdLog: StdLog): Promise<void>;
|
|
19
|
+
setCurrentHook(hookDetails: CurrentRunInfo): void;
|
|
15
20
|
configureGit(): Promise<void>;
|
|
16
21
|
static getTests(): Record<string, TestMeta>;
|
|
17
22
|
onSuiteStart(suiteStats: SuiteStats): void;
|
package/build/reporter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAO5F,OAAO,
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAO5F,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,EAAY,QAAQ,EAAc,MAAM,SAAS,CAAA;AAczG,cAAM,aAAc,SAAQ,YAAY;IACpC,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,OAAO,CAAC,CAAyC;IACzD,OAAO,CAAC,cAAc,CAAO;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,oBAAoB,CAAoC;IAChE,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,MAAM,CAAC,MAAM,CAA+B;IACpD,OAAO,CAAC,cAAc,CAAC,CAAQ;IAC/B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,YAAY,CAAqB;IAEnC,aAAa,CAAE,WAAW,EAAE,WAAW;IAS7C,iBAAiB;IAQJ,iBAAiB,CAAC,MAAM,EAAE,MAAM;IAc7C,cAAc,CAAC,WAAW,EAAE,cAAc;IAapC,YAAY;IAWlB,MAAM,CAAC,QAAQ;IAIf,YAAY,CAAE,UAAU,EAAE,UAAU;IAoBpC,UAAU;IAIV,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAe1C,SAAS,CAAC,SAAS,EAAE,SAAS;IAQ9B,WAAW,CAAC,SAAS,EAAE,SAAS;IAahC,WAAW,CAAC,SAAS,EAAE,SAAS;IAehC,SAAS,CAAC,SAAS,EAAE,SAAS;IAqBpC,iBAAiB,CAAC,SAAS,EAAE,SAAS;IAIhC,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAC,SAAS,EAAE,SAAS,EAAE,MAAM;IAkFlE,UAAU,CAAE,SAAS,EAAE,SAAS;CAQzC;AAED,QAAA,MAAM,YAAY,EAAE,OAAO,aAAoD,CAAA;AAC/E,KAAK,YAAY,GAAG,aAAa,CAAA;AACjC,eAAe,YAAY,CAAA"}
|
package/build/reporter.js
CHANGED
|
@@ -19,6 +19,8 @@ class _TestReporter extends reporter_1.default {
|
|
|
19
19
|
this._requestQueueHandler = request_handler_1.default.getInstance();
|
|
20
20
|
this._suites = [];
|
|
21
21
|
this._gitConfigured = false;
|
|
22
|
+
this._currentHook = {};
|
|
23
|
+
this._currentTest = {};
|
|
22
24
|
}
|
|
23
25
|
async onRunnerStart(runnerStats) {
|
|
24
26
|
this._capabilities = runnerStats.capabilities;
|
|
@@ -27,6 +29,41 @@ class _TestReporter extends reporter_1.default {
|
|
|
27
29
|
if (typeof this._config.testObservability !== 'undefined')
|
|
28
30
|
this._observability = this._config.testObservability;
|
|
29
31
|
await this.configureGit();
|
|
32
|
+
this.registerListeners();
|
|
33
|
+
}
|
|
34
|
+
registerListeners() {
|
|
35
|
+
var _a;
|
|
36
|
+
if (((_a = this._config) === null || _a === void 0 ? void 0 : _a.framework) !== 'jasmine') {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
process.removeAllListeners(`bs:addLog:${process.pid}`);
|
|
40
|
+
process.on(`bs:addLog:${process.pid}`, this.appendTestItemLog.bind(this));
|
|
41
|
+
}
|
|
42
|
+
async appendTestItemLog(stdLog) {
|
|
43
|
+
if (this._currentHook.uuid && !this._currentHook.finished) {
|
|
44
|
+
stdLog.hook_run_uuid = this._currentHook.uuid;
|
|
45
|
+
}
|
|
46
|
+
else if (this._currentTest.uuid) {
|
|
47
|
+
stdLog.test_run_uuid = this._currentTest.uuid;
|
|
48
|
+
}
|
|
49
|
+
if (stdLog.hook_run_uuid || stdLog.test_run_uuid) {
|
|
50
|
+
await (0, util_1.pushDataToQueue)({
|
|
51
|
+
event_type: 'LogCreated',
|
|
52
|
+
logs: [stdLog]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
setCurrentHook(hookDetails) {
|
|
57
|
+
if (hookDetails.finished) {
|
|
58
|
+
if (this._currentHook.uuid === hookDetails.uuid) {
|
|
59
|
+
this._currentHook.finished = true;
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this._currentHook = {
|
|
64
|
+
uuid: hookDetails.uuid,
|
|
65
|
+
finished: false
|
|
66
|
+
};
|
|
30
67
|
}
|
|
31
68
|
async configureGit() {
|
|
32
69
|
if (this._gitConfigured) {
|
|
@@ -92,8 +129,10 @@ class _TestReporter extends reporter_1.default {
|
|
|
92
129
|
return;
|
|
93
130
|
if (testStats.fullTitle === '<unknown test>')
|
|
94
131
|
return;
|
|
132
|
+
const uuid = (0, uuid_1.v4)();
|
|
133
|
+
this._currentTest.uuid = uuid;
|
|
95
134
|
_TestReporter._tests[testStats.fullTitle] = {
|
|
96
|
-
uuid:
|
|
135
|
+
uuid: uuid,
|
|
97
136
|
};
|
|
98
137
|
await this.sendTestRunEvent(testStats, 'TestRunStarted');
|
|
99
138
|
}
|
|
@@ -103,6 +142,7 @@ class _TestReporter extends reporter_1.default {
|
|
|
103
142
|
}
|
|
104
143
|
const identifier = this.getHookIdentifier(hookStats);
|
|
105
144
|
const hookId = (0, uuid_1.v4)();
|
|
145
|
+
this.setCurrentHook({ uuid: hookId });
|
|
106
146
|
_TestReporter._tests[identifier] = {
|
|
107
147
|
uuid: hookId,
|
|
108
148
|
startedAt: (new Date()).toISOString()
|
|
@@ -122,6 +162,7 @@ class _TestReporter extends reporter_1.default {
|
|
|
122
162
|
finishedAt: (new Date()).toISOString()
|
|
123
163
|
};
|
|
124
164
|
}
|
|
165
|
+
this.setCurrentHook({ uuid: _TestReporter._tests[identifier].uuid, finished: true });
|
|
125
166
|
if (!hookStats.state && !hookStats.error) {
|
|
126
167
|
hookStats.state = 'passed';
|
|
127
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-handler.d.ts","sourceRoot":"","sources":["../src/request-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAKzC,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,sBAAsB,CAAC,CAAgC;IACxD,cAAc,SAAI;
|
|
1
|
+
{"version":3,"file":"request-handler.d.ts","sourceRoot":"","sources":["../src/request-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAKzC,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,sBAAsB,CAAC,CAAgC;IACxD,cAAc,SAAI;IAClB,eAAe,UAAQ;IAE9B,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAA;IAGpC,OAAO;WAGO,WAAW,IAAI,mBAAmB;IAOhD,KAAK;IAOL,GAAG,CAAE,KAAK,EAAE,UAAU;;;;;;;;;IAuChB,QAAQ;IAQd,sBAAsB;IAUtB,sBAAsB;IAKtB,uBAAuB,CAAE,GAAG,EAAE,MAAM;IAQpC,aAAa;CAOhB"}
|
package/build/request-handler.js
CHANGED
|
@@ -13,6 +13,7 @@ class RequestQueueHandler {
|
|
|
13
13
|
this.queue = [];
|
|
14
14
|
this.started = false;
|
|
15
15
|
this.pendingUploads = 0;
|
|
16
|
+
this.tearDownInvoked = false;
|
|
16
17
|
}
|
|
17
18
|
static getInstance() {
|
|
18
19
|
if (!RequestQueueHandler.instance) {
|
|
@@ -87,6 +88,10 @@ class RequestQueueHandler {
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
shouldProceed() {
|
|
91
|
+
if (this.tearDownInvoked) {
|
|
92
|
+
log.debug('Force request-queue shutdown, as test run event is received after teardown');
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
90
95
|
return this.queue.length >= constants_1.DATA_BATCH_SIZE;
|
|
91
96
|
}
|
|
92
97
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function testStartEvent(): void;
|
|
2
|
+
export declare function testForceStop(): void;
|
|
3
|
+
export declare function testStop(this: any): void;
|
|
4
|
+
export declare function accessibilityResults(): Promise<Array<{
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}>>;
|
|
7
|
+
export declare function accessibilityResultsSummary(): Promise<{
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=test-event-scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-event-scripts.d.ts","sourceRoot":"","sources":["../../src/scripts/test-event-scripts.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,SAY7B;AAED,wBAAgB,aAAa,SAG5B;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,QAgBjC;AAED,wBAAgB,oBAAoB,IAAK,OAAO,CAAC,KAAK,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CAAE,CAAC,CAAC,CAc/E;AAED,wBAAgB,2BAA2B,IAAK,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CAAE,CAAC,CAc/E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.accessibilityResultsSummary = exports.accessibilityResults = exports.testStop = exports.testForceStop = exports.testStartEvent = void 0;
|
|
4
|
+
function testStartEvent() {
|
|
5
|
+
const callback = arguments[arguments.length - 1];
|
|
6
|
+
const fn = () => {
|
|
7
|
+
window.addEventListener('A11Y_TAP_STARTED', fn2);
|
|
8
|
+
const e = new CustomEvent('A11Y_FORCE_START');
|
|
9
|
+
window.dispatchEvent(e);
|
|
10
|
+
};
|
|
11
|
+
const fn2 = () => {
|
|
12
|
+
window.removeEventListener('A11Y_TAP_STARTED', fn);
|
|
13
|
+
callback();
|
|
14
|
+
};
|
|
15
|
+
fn();
|
|
16
|
+
}
|
|
17
|
+
exports.testStartEvent = testStartEvent;
|
|
18
|
+
function testForceStop() {
|
|
19
|
+
const e = new CustomEvent('A11Y_FORCE_STOP');
|
|
20
|
+
window.dispatchEvent(e);
|
|
21
|
+
}
|
|
22
|
+
exports.testForceStop = testForceStop;
|
|
23
|
+
function testStop() {
|
|
24
|
+
const callback = arguments[arguments.length - 1];
|
|
25
|
+
this.res = null;
|
|
26
|
+
if (arguments[0].saveResults) {
|
|
27
|
+
window.addEventListener('A11Y_TAP_TRANSPORTER', (event) => {
|
|
28
|
+
window.tapTransporterData = event.detail;
|
|
29
|
+
this.res = window.tapTransporterData;
|
|
30
|
+
callback(this.res);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const e = new CustomEvent('A11Y_TEST_END', { detail: arguments[0] });
|
|
34
|
+
window.dispatchEvent(e);
|
|
35
|
+
if (arguments[0].saveResults !== true) {
|
|
36
|
+
callback();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.testStop = testStop;
|
|
40
|
+
function accessibilityResults() {
|
|
41
|
+
return new Promise(function (resolve, reject) {
|
|
42
|
+
try {
|
|
43
|
+
const event = new CustomEvent('A11Y_TAP_GET_RESULTS');
|
|
44
|
+
const fn = function (event) {
|
|
45
|
+
window.removeEventListener('A11Y_RESULTS_RESPONSE', fn);
|
|
46
|
+
resolve(event.detail.data);
|
|
47
|
+
};
|
|
48
|
+
window.addEventListener('A11Y_RESULTS_RESPONSE', fn);
|
|
49
|
+
window.dispatchEvent(event);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
reject();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.accessibilityResults = accessibilityResults;
|
|
57
|
+
function accessibilityResultsSummary() {
|
|
58
|
+
return new Promise(function (resolve, reject) {
|
|
59
|
+
try {
|
|
60
|
+
const event = new CustomEvent('A11Y_TAP_GET_RESULTS_SUMMARY');
|
|
61
|
+
const fn = function (event) {
|
|
62
|
+
window.removeEventListener('A11Y_RESULTS_SUMMARY_RESPONSE', fn);
|
|
63
|
+
resolve(event.detail.summary);
|
|
64
|
+
};
|
|
65
|
+
window.addEventListener('A11Y_RESULTS_SUMMARY_RESPONSE', fn);
|
|
66
|
+
window.dispatchEvent(event);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
reject();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.accessibilityResultsSummary = accessibilityResultsSummary;
|