@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
package/build/launcher.js
CHANGED
|
@@ -36,7 +36,6 @@ 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");
|
|
40
39
|
// @ts-ignore
|
|
41
40
|
const package_json_1 = require("../package.json");
|
|
42
41
|
const crash_reporter_1 = __importDefault(require("./crash-reporter"));
|
|
@@ -45,15 +44,19 @@ const constants_1 = require("./constants");
|
|
|
45
44
|
const util_2 = require("./util");
|
|
46
45
|
const performance_tester_1 = __importDefault(require("./performance-tester"));
|
|
47
46
|
const PercyLogger_1 = require("./Percy/PercyLogger");
|
|
47
|
+
const exitHandler_1 = require("./exitHandler");
|
|
48
|
+
const config_1 = __importDefault(require("./config"));
|
|
49
|
+
const funnelInstrumentation_1 = require("./instrumentation/funnelInstrumentation");
|
|
48
50
|
const log = (0, logger_1.default)('@wdio/browserstack-service');
|
|
49
51
|
class BrowserstackLauncherService {
|
|
50
52
|
constructor(_options, capabilities, _config) {
|
|
51
53
|
this._options = _options;
|
|
52
54
|
this._config = _config;
|
|
53
55
|
PercyLogger_1.PercyLogger.clearLogFile();
|
|
56
|
+
(0, exitHandler_1.setupExitHandlers)();
|
|
54
57
|
// added to maintain backward compatibility with webdriverIO v5
|
|
55
|
-
this.setupExitHandlers();
|
|
56
58
|
this._config || (this._config = _options);
|
|
59
|
+
this.browserStackConfig = config_1.default.getInstance(_options, _config);
|
|
57
60
|
if (Array.isArray(capabilities)) {
|
|
58
61
|
capabilities.forEach((capability) => {
|
|
59
62
|
var _a, _b;
|
|
@@ -127,7 +130,9 @@ class BrowserstackLauncherService {
|
|
|
127
130
|
}
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
|
-
|
|
133
|
+
this.browserStackConfig.buildIdentifier = this._buildIdentifier;
|
|
134
|
+
this.browserStackConfig.buildName = this._buildName;
|
|
135
|
+
if (process.env[constants_1.PERF_MEASUREMENT_ENV]) {
|
|
131
136
|
performance_tester_1.default.startMonitoring('performance-report-launcher.csv');
|
|
132
137
|
}
|
|
133
138
|
this._accessibilityAutomation || (this._accessibilityAutomation = (0, util_2.isTrue)(this._options.accessibility));
|
|
@@ -136,8 +141,8 @@ class BrowserstackLauncherService {
|
|
|
136
141
|
this._options.testObservability = this._options.testObservability == false ? false : true;
|
|
137
142
|
if (this._options.testObservability &&
|
|
138
143
|
// update files to run if it's a rerun
|
|
139
|
-
process.env.
|
|
140
|
-
this._config.specs = process.env.
|
|
144
|
+
process.env[constants_1.RERUN_ENV] && process.env[constants_1.RERUN_TESTS_ENV]) {
|
|
145
|
+
this._config.specs = process.env[constants_1.RERUN_TESTS_ENV].split(',');
|
|
141
146
|
}
|
|
142
147
|
try {
|
|
143
148
|
crash_reporter_1.default.setConfigDetails(this._config, capabilities, this._options);
|
|
@@ -159,16 +164,9 @@ class BrowserstackLauncherService {
|
|
|
159
164
|
PercyLogger_1.PercyLogger.error(`Error while setting best platform for Percy snapshot at worker start ${err}`);
|
|
160
165
|
}
|
|
161
166
|
}
|
|
162
|
-
setupExitHandlers() {
|
|
163
|
-
process.on('exit', (code) => {
|
|
164
|
-
if (!!process.env.BS_TESTOPS_JWT && !this._testOpsBuildStopped) {
|
|
165
|
-
const childProcess = (0, node_child_process_1.spawn)('node', [`${path_1.default.join(__dirname, 'cleanup.js')}`], { detached: true, stdio: 'inherit', env: { ...process.env } });
|
|
166
|
-
childProcess.unref();
|
|
167
|
-
process.exit(code);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
167
|
async onPrepare(config, capabilities) {
|
|
168
|
+
// // Send Funnel start request
|
|
169
|
+
await (0, funnelInstrumentation_1.sendStart)(this.browserStackConfig);
|
|
172
170
|
/**
|
|
173
171
|
* Upload app to BrowserStack if valid file path to app is given.
|
|
174
172
|
* Update app value of capability directly if app_url, custom_id, shareable_id is given
|
|
@@ -316,12 +314,12 @@ class BrowserstackLauncherService {
|
|
|
316
314
|
if (this._options.testObservability) {
|
|
317
315
|
log.debug('Sending stop launch event');
|
|
318
316
|
await (0, util_2.stopBuildUpstream)();
|
|
319
|
-
if (process.env.
|
|
320
|
-
console.log(`\nVisit https://observability.browserstack.com/builds/${process.env.
|
|
321
|
-
this.
|
|
317
|
+
if (process.env[constants_1.TESTOPS_BUILD_ID_ENV]) {
|
|
318
|
+
console.log(`\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`);
|
|
319
|
+
this.browserStackConfig.testObservability.buildStopped = true;
|
|
322
320
|
}
|
|
323
321
|
}
|
|
324
|
-
if (process.env.
|
|
322
|
+
if (process.env[constants_1.PERF_MEASUREMENT_ENV]) {
|
|
325
323
|
await performance_tester_1.default.stopAndGenerate('performance-launcher.html');
|
|
326
324
|
performance_tester_1.default.calculateTimes(['launchTestSession', 'stopBuildUpstream']);
|
|
327
325
|
if (!process.env.START_TIME) {
|
|
@@ -334,6 +332,7 @@ class BrowserstackLauncherService {
|
|
|
334
332
|
await this.stopPercy();
|
|
335
333
|
}
|
|
336
334
|
PercyLogger_1.PercyLogger.clearLogger();
|
|
335
|
+
await (0, funnelInstrumentation_1.sendFinish)(this.browserStackConfig);
|
|
337
336
|
if (!this.browserstackLocal || !this.browserstackLocal.isRunning()) {
|
|
338
337
|
return;
|
|
339
338
|
}
|
|
@@ -402,8 +401,10 @@ class BrowserstackLauncherService {
|
|
|
402
401
|
async _uploadApp(app) {
|
|
403
402
|
log.info(`uploading app ${app.app} ${app.customId ? `and custom_id: ${app.customId}` : ''} to browserstack`);
|
|
404
403
|
const form = new form_data_1.default();
|
|
405
|
-
if (app.app)
|
|
406
|
-
|
|
404
|
+
if (app.app) {
|
|
405
|
+
const fileName = path_1.default.basename(app.app);
|
|
406
|
+
form.append('file', fs_1.default.createReadStream(app.app), fileName);
|
|
407
|
+
}
|
|
407
408
|
if (app.customId)
|
|
408
409
|
form.append('custom_id', app.customId);
|
|
409
410
|
const res = await got_1.default.post('https://api-cloud.browserstack.com/app-automate/upload', {
|
package/build/reporter.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import WDIOReporter, { SuiteStats, TestStats, RunnerStats, HookStats } from '@wdio/reporter';
|
|
2
|
-
import type { CurrentRunInfo, StdLog, TestMeta } from './types';
|
|
2
|
+
import type { CurrentRunInfo, StdLog, TestData, TestMeta } from './types';
|
|
3
3
|
declare class _TestReporter extends WDIOReporter {
|
|
4
4
|
private _capabilities;
|
|
5
5
|
private _config?;
|
|
6
6
|
private _observability;
|
|
7
7
|
private _sessionId?;
|
|
8
8
|
private _suiteName?;
|
|
9
|
-
private _requestQueueHandler;
|
|
10
9
|
private _suites;
|
|
11
10
|
private static _tests;
|
|
12
11
|
private _gitConfigPath?;
|
|
13
12
|
private _gitConfigured;
|
|
14
13
|
private _currentHook;
|
|
15
14
|
private _currentTest;
|
|
15
|
+
private _userCaps?;
|
|
16
|
+
private listener;
|
|
16
17
|
onRunnerStart(runnerStats: RunnerStats): Promise<void>;
|
|
17
18
|
registerListeners(): void;
|
|
19
|
+
private getUserCaps;
|
|
18
20
|
appendTestItemLog(stdLog: StdLog): Promise<void>;
|
|
19
21
|
setCurrentHook(hookDetails: CurrentRunInfo): void;
|
|
20
22
|
configureGit(): Promise<void>;
|
|
@@ -27,7 +29,7 @@ declare class _TestReporter extends WDIOReporter {
|
|
|
27
29
|
onHookStart(hookStats: HookStats): Promise<void>;
|
|
28
30
|
onHookEnd(hookStats: HookStats): Promise<void>;
|
|
29
31
|
getHookIdentifier(hookStats: HookStats): string;
|
|
30
|
-
|
|
32
|
+
getRunData(testStats: TestStats | HookStats, eventType: string): Promise<TestData>;
|
|
31
33
|
onTestSkip(testStats: TestStats): Promise<void>;
|
|
32
34
|
}
|
|
33
35
|
declare const TestReporter: typeof _TestReporter;
|
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,KAAK,EAAsB,cAAc,EAAE,MAAM,
|
|
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,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAa7F,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,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;IACzC,OAAO,CAAC,SAAS,CAAC,CAAoC;IACtD,OAAO,CAAC,QAAQ,CAAyB;IAEnC,aAAa,CAAE,WAAW,EAAE,WAAW;IAU7C,iBAAiB;IAQjB,OAAO,CAAC,WAAW;IAIN,iBAAiB,CAAC,MAAM,EAAE,MAAM;IAW7C,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,UAAU,CAAC,SAAS,EAAE,SAAS,GAAC,SAAS,EAAE,SAAS,EAAE,MAAM;IAyE5D,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
|
@@ -9,21 +9,23 @@ const reporter_1 = __importDefault(require("@wdio/reporter"));
|
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
10
10
|
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
11
11
|
const util_1 = require("./util");
|
|
12
|
-
const
|
|
12
|
+
const listener_1 = __importDefault(require("./testOps/listener"));
|
|
13
13
|
const log = (0, logger_1.default)('@wdio/browserstack-service');
|
|
14
14
|
class _TestReporter extends reporter_1.default {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
17
|
this._capabilities = {};
|
|
18
18
|
this._observability = true;
|
|
19
|
-
this._requestQueueHandler = request_handler_1.default.getInstance();
|
|
20
19
|
this._suites = [];
|
|
21
20
|
this._gitConfigured = false;
|
|
22
21
|
this._currentHook = {};
|
|
23
22
|
this._currentTest = {};
|
|
23
|
+
this._userCaps = {};
|
|
24
|
+
this.listener = listener_1.default.getInstance();
|
|
24
25
|
}
|
|
25
26
|
async onRunnerStart(runnerStats) {
|
|
26
27
|
this._capabilities = runnerStats.capabilities;
|
|
28
|
+
this._userCaps = this.getUserCaps(runnerStats);
|
|
27
29
|
this._config = runnerStats.config;
|
|
28
30
|
this._sessionId = runnerStats.sessionId;
|
|
29
31
|
if (typeof this._config.testObservability !== 'undefined')
|
|
@@ -39,6 +41,10 @@ class _TestReporter extends reporter_1.default {
|
|
|
39
41
|
process.removeAllListeners(`bs:addLog:${process.pid}`);
|
|
40
42
|
process.on(`bs:addLog:${process.pid}`, this.appendTestItemLog.bind(this));
|
|
41
43
|
}
|
|
44
|
+
getUserCaps(runnerStats) {
|
|
45
|
+
var _a;
|
|
46
|
+
return (_a = runnerStats.instanceOptions[runnerStats.sessionId]) === null || _a === void 0 ? void 0 : _a.capabilities;
|
|
47
|
+
}
|
|
42
48
|
async appendTestItemLog(stdLog) {
|
|
43
49
|
if (this._currentHook.uuid && !this._currentHook.finished) {
|
|
44
50
|
stdLog.hook_run_uuid = this._currentHook.uuid;
|
|
@@ -47,10 +53,7 @@ class _TestReporter extends reporter_1.default {
|
|
|
47
53
|
stdLog.test_run_uuid = this._currentTest.uuid;
|
|
48
54
|
}
|
|
49
55
|
if (stdLog.hook_run_uuid || stdLog.test_run_uuid) {
|
|
50
|
-
|
|
51
|
-
event_type: 'LogCreated',
|
|
52
|
-
logs: [stdLog]
|
|
53
|
-
});
|
|
56
|
+
this.listener.logCreated([stdLog]);
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
setCurrentHook(hookDetails) {
|
|
@@ -122,7 +125,7 @@ class _TestReporter extends reporter_1.default {
|
|
|
122
125
|
if (testStats.fullTitle === '<unknown test>')
|
|
123
126
|
return;
|
|
124
127
|
testStats.end || (testStats.end = new Date());
|
|
125
|
-
await this.
|
|
128
|
+
this.listener.testFinished(await this.getRunData(testStats, 'TestRunFinished'));
|
|
126
129
|
}
|
|
127
130
|
async onTestStart(testStats) {
|
|
128
131
|
if (!this.needToSendData('test', 'start'))
|
|
@@ -134,7 +137,7 @@ class _TestReporter extends reporter_1.default {
|
|
|
134
137
|
_TestReporter._tests[testStats.fullTitle] = {
|
|
135
138
|
uuid: uuid,
|
|
136
139
|
};
|
|
137
|
-
await this.
|
|
140
|
+
this.listener.testStarted(await this.getRunData(testStats, 'TestRunStarted'));
|
|
138
141
|
}
|
|
139
142
|
async onHookStart(hookStats) {
|
|
140
143
|
if (!this.needToSendData('hook', 'start')) {
|
|
@@ -147,7 +150,7 @@ class _TestReporter extends reporter_1.default {
|
|
|
147
150
|
uuid: hookId,
|
|
148
151
|
startedAt: (new Date()).toISOString()
|
|
149
152
|
};
|
|
150
|
-
await this.
|
|
153
|
+
this.listener.hookStarted(await this.getRunData(hookStats, 'HookRunStarted'));
|
|
151
154
|
}
|
|
152
155
|
async onHookEnd(hookStats) {
|
|
153
156
|
if (!this.needToSendData('hook', 'end')) {
|
|
@@ -166,13 +169,13 @@ class _TestReporter extends reporter_1.default {
|
|
|
166
169
|
if (!hookStats.state && !hookStats.error) {
|
|
167
170
|
hookStats.state = 'passed';
|
|
168
171
|
}
|
|
169
|
-
await this.
|
|
172
|
+
this.listener.hookFinished(await this.getRunData(hookStats, 'HookRunFinished'));
|
|
170
173
|
}
|
|
171
174
|
getHookIdentifier(hookStats) {
|
|
172
175
|
var _a;
|
|
173
176
|
return `${hookStats.title} for ${(_a = this._suites.at(-1)) === null || _a === void 0 ? void 0 : _a.title}`;
|
|
174
177
|
}
|
|
175
|
-
async
|
|
178
|
+
async getRunData(testStats, eventType) {
|
|
176
179
|
var _a, _b, _c, _d, _e, _f;
|
|
177
180
|
const framework = (_a = this._config) === null || _a === void 0 ? void 0 : _a.framework;
|
|
178
181
|
const scopes = this._suites.map(s => s.title);
|
|
@@ -214,6 +217,7 @@ class _TestReporter extends reporter_1.default {
|
|
|
214
217
|
browser: (_c = this._capabilities) === null || _c === void 0 ? void 0 : _c.browserName,
|
|
215
218
|
browser_version: (_d = this._capabilities) === null || _d === void 0 ? void 0 : _d.browserVersion,
|
|
216
219
|
platform: (_e = this._capabilities) === null || _e === void 0 ? void 0 : _e.platformName,
|
|
220
|
+
platform_version: (0, util_1.getPlatformVersion)(this._userCaps)
|
|
217
221
|
};
|
|
218
222
|
}
|
|
219
223
|
if (eventType == 'TestRunFinished' || eventType == 'HookRunFinished') {
|
|
@@ -231,20 +235,10 @@ class _TestReporter extends reporter_1.default {
|
|
|
231
235
|
if (eventType == 'TestRunSkipped') {
|
|
232
236
|
eventType = 'TestRunFinished';
|
|
233
237
|
}
|
|
234
|
-
const uploadData = {
|
|
235
|
-
event_type: eventType,
|
|
236
|
-
};
|
|
237
238
|
if (eventType.match(/HookRun/)) {
|
|
238
239
|
testData.hook_type = ((_f = testData.name) === null || _f === void 0 ? void 0 : _f.toLowerCase()) ? (0, util_1.getHookType)(testData.name.toLowerCase()) : 'undefined';
|
|
239
|
-
uploadData.hook_run = testData;
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
uploadData.test_run = testData;
|
|
243
|
-
}
|
|
244
|
-
const req = this._requestQueueHandler.add(uploadData);
|
|
245
|
-
if (req.proceed && req.data) {
|
|
246
|
-
await (0, util_1.uploadEventData)(req.data, req.url);
|
|
247
240
|
}
|
|
241
|
+
return testData;
|
|
248
242
|
}
|
|
249
243
|
async onTestSkip(testStats) {
|
|
250
244
|
// cucumber steps call this method. We don't want step skipped state so skip for cucumber
|
|
@@ -252,7 +246,7 @@ class _TestReporter extends reporter_1.default {
|
|
|
252
246
|
return;
|
|
253
247
|
testStats.start || (testStats.start = new Date());
|
|
254
248
|
testStats.end || (testStats.end = new Date());
|
|
255
|
-
await this.
|
|
249
|
+
this.listener.testFinished(await this.getRunData(testStats, 'TestRunSkipped'));
|
|
256
250
|
}
|
|
257
251
|
}
|
|
258
252
|
_TestReporter._tests = {};
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
import type { UploadType } from './types';
|
|
2
2
|
export default class RequestQueueHandler {
|
|
3
3
|
private queue;
|
|
4
|
-
private started;
|
|
5
4
|
private pollEventBatchInterval?;
|
|
6
|
-
|
|
5
|
+
private readonly callback?;
|
|
7
6
|
tearDownInvoked: boolean;
|
|
8
7
|
static instance: RequestQueueHandler;
|
|
9
8
|
private constructor();
|
|
10
|
-
static getInstance(): RequestQueueHandler;
|
|
11
|
-
|
|
12
|
-
add(event: UploadType): {
|
|
13
|
-
proceed: boolean;
|
|
14
|
-
data?: undefined;
|
|
15
|
-
url?: undefined;
|
|
16
|
-
} | {
|
|
17
|
-
proceed: boolean;
|
|
18
|
-
data: UploadType[] | undefined;
|
|
19
|
-
url: string;
|
|
20
|
-
};
|
|
9
|
+
static getInstance(callback?: Function): RequestQueueHandler;
|
|
10
|
+
add(event: UploadType): void;
|
|
21
11
|
shutdown(): Promise<void>;
|
|
22
12
|
startEventBatchPolling(): void;
|
|
23
13
|
resetEventBatchPolling(): void;
|
|
24
14
|
removeEventBatchPolling(tag: string): void;
|
|
15
|
+
sendBatch(): Promise<void>;
|
|
16
|
+
callCallback: (data: UploadType[], kind: string) => Promise<void>;
|
|
25
17
|
shouldProceed(): boolean;
|
|
26
18
|
}
|
|
27
19
|
//# sourceMappingURL=request-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-handler.d.ts","sourceRoot":"","sources":["../src/request-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-handler.d.ts","sourceRoot":"","sources":["../src/request-handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAKzC,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,sBAAsB,CAAC,CAAgC;IAC/D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAU;IAC7B,eAAe,UAAQ;IAE9B,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAA;IAGpC,OAAO;WAKO,WAAW,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,mBAAmB;IAOnE,GAAG,CAAE,KAAK,EAAE,UAAU;IAehB,QAAQ;IAQd,sBAAsB;IAItB,sBAAsB;IAKtB,uBAAuB,CAAE,GAAG,EAAE,MAAM;IAO9B,SAAS;IASf,YAAY,SAAgB,UAAU,EAAE,QAAQ,MAAM,mBAGrD;IAED,aAAa;CAOhB"}
|
package/build/request-handler.js
CHANGED
|
@@ -5,76 +5,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
7
7
|
const constants_1 = require("./constants");
|
|
8
|
-
const
|
|
8
|
+
const bstackLogger_1 = require("./bstackLogger");
|
|
9
9
|
const log = (0, logger_1.default)('@wdio/browserstack-service');
|
|
10
10
|
class RequestQueueHandler {
|
|
11
11
|
// making it private to use singleton pattern
|
|
12
|
-
constructor() {
|
|
12
|
+
constructor(callback) {
|
|
13
13
|
this.queue = [];
|
|
14
|
-
this.started = false;
|
|
15
|
-
this.pendingUploads = 0;
|
|
16
14
|
this.tearDownInvoked = false;
|
|
15
|
+
this.callCallback = async (data, kind) => {
|
|
16
|
+
bstackLogger_1.BStackLogger.debug('calling callback with kind ' + kind);
|
|
17
|
+
this.callback && await this.callback(data);
|
|
18
|
+
};
|
|
19
|
+
this.callback = callback;
|
|
20
|
+
this.startEventBatchPolling();
|
|
17
21
|
}
|
|
18
|
-
static getInstance() {
|
|
19
|
-
if (!RequestQueueHandler.instance) {
|
|
20
|
-
RequestQueueHandler.instance = new RequestQueueHandler();
|
|
22
|
+
static getInstance(callback) {
|
|
23
|
+
if (!RequestQueueHandler.instance && callback) {
|
|
24
|
+
RequestQueueHandler.instance = new RequestQueueHandler(callback);
|
|
21
25
|
}
|
|
22
26
|
return RequestQueueHandler.instance;
|
|
23
27
|
}
|
|
24
|
-
start() {
|
|
25
|
-
if (!this.started) {
|
|
26
|
-
this.started = true;
|
|
27
|
-
this.startEventBatchPolling();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
28
|
add(event) {
|
|
31
|
-
if (!process.env.
|
|
32
|
-
|
|
33
|
-
proceed: false
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if (!constants_1.BATCH_EVENT_TYPES.includes(event.event_type)) {
|
|
37
|
-
return {
|
|
38
|
-
proceed: true
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
if (event.logs && event.logs[0] && event.logs[0].kind === 'TEST_SCREENSHOT') {
|
|
42
|
-
return {
|
|
43
|
-
proceed: true,
|
|
44
|
-
data: [event],
|
|
45
|
-
url: constants_1.DATA_SCREENSHOT_ENDPOINT
|
|
46
|
-
};
|
|
29
|
+
if (!process.env[constants_1.TESTOPS_BUILD_COMPLETED_ENV]) {
|
|
30
|
+
throw new Error('Observability build start not completed yet.');
|
|
47
31
|
}
|
|
48
32
|
this.queue.push(event);
|
|
49
|
-
|
|
50
|
-
let data;
|
|
33
|
+
bstackLogger_1.BStackLogger.debug(`Added data to request queue. Queue length = ${this.queue.length}`);
|
|
51
34
|
const shouldProceed = this.shouldProceed();
|
|
52
35
|
if (shouldProceed) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
this.sendBatch().catch((e) => {
|
|
37
|
+
bstackLogger_1.BStackLogger.debug('Exception in sending batch: ' + e);
|
|
38
|
+
});
|
|
56
39
|
}
|
|
57
|
-
return {
|
|
58
|
-
proceed: shouldProceed,
|
|
59
|
-
data: data,
|
|
60
|
-
url: constants_1.DATA_BATCH_ENDPOINT
|
|
61
|
-
};
|
|
62
40
|
}
|
|
63
41
|
async shutdown() {
|
|
64
42
|
this.removeEventBatchPolling('Shutting down');
|
|
65
43
|
while (this.queue.length > 0) {
|
|
66
44
|
const data = this.queue.splice(0, constants_1.DATA_BATCH_SIZE);
|
|
67
|
-
await
|
|
45
|
+
await this.callCallback(data, 'SHUTDOWN_QUEUE');
|
|
68
46
|
}
|
|
69
47
|
}
|
|
70
48
|
startEventBatchPolling() {
|
|
71
|
-
this.pollEventBatchInterval = setInterval(
|
|
72
|
-
if (this.queue.length > 0) {
|
|
73
|
-
const data = this.queue.splice(0, constants_1.DATA_BATCH_SIZE);
|
|
74
|
-
log.debug(`Sending data from request queue. Data length = ${data.length}, Queue length after removal = ${this.queue.length}`);
|
|
75
|
-
await (0, util_1.batchAndPostEvents)(constants_1.DATA_BATCH_ENDPOINT, 'INTERVAL_QUEUE', data);
|
|
76
|
-
}
|
|
77
|
-
}, constants_1.DATA_BATCH_INTERVAL);
|
|
49
|
+
this.pollEventBatchInterval = setInterval(this.sendBatch.bind(this), constants_1.DATA_BATCH_INTERVAL);
|
|
78
50
|
}
|
|
79
51
|
resetEventBatchPolling() {
|
|
80
52
|
this.removeEventBatchPolling('Resetting');
|
|
@@ -84,9 +56,16 @@ class RequestQueueHandler {
|
|
|
84
56
|
if (this.pollEventBatchInterval) {
|
|
85
57
|
log.debug(`${tag} request queue`);
|
|
86
58
|
clearInterval(this.pollEventBatchInterval);
|
|
87
|
-
this.started = false;
|
|
88
59
|
}
|
|
89
60
|
}
|
|
61
|
+
async sendBatch() {
|
|
62
|
+
const data = this.queue.splice(0, constants_1.DATA_BATCH_SIZE);
|
|
63
|
+
if (data.length === 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
bstackLogger_1.BStackLogger.debug(`Sending data from request queue. Data length = ${data.length}, Queue length after removal = ${this.queue.length}`);
|
|
67
|
+
await this.callCallback(data, 'INTERVAL_QUEUE');
|
|
68
|
+
}
|
|
90
69
|
shouldProceed() {
|
|
91
70
|
if (this.tearDownInvoked) {
|
|
92
71
|
log.debug('Force request-queue shutdown, as test run event is received after teardown');
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare class AccessibilityScripts {
|
|
2
|
+
private static instance;
|
|
3
|
+
performScan: string | null;
|
|
4
|
+
getResults: string | null;
|
|
5
|
+
getResultsSummary: string | null;
|
|
6
|
+
saveTestResults: string | null;
|
|
7
|
+
commandsToWrap: Array<any> | null;
|
|
8
|
+
browserstackFolderPath: string;
|
|
9
|
+
commandsPath: string;
|
|
10
|
+
private constructor();
|
|
11
|
+
static checkAndGetInstance(): AccessibilityScripts;
|
|
12
|
+
readFromExistingFile(): void;
|
|
13
|
+
update(data: {
|
|
14
|
+
commands: [any];
|
|
15
|
+
scripts: {
|
|
16
|
+
scan: null;
|
|
17
|
+
getResults: null;
|
|
18
|
+
getResultsSummary: null;
|
|
19
|
+
saveResults: null;
|
|
20
|
+
};
|
|
21
|
+
}): void;
|
|
22
|
+
store(): void;
|
|
23
|
+
}
|
|
24
|
+
declare const _default: AccessibilityScripts;
|
|
25
|
+
export default _default;
|
|
26
|
+
//# sourceMappingURL=accessibility-scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility-scripts.d.ts","sourceRoot":"","sources":["../../src/scripts/accessibility-scripts.ts"],"names":[],"mappings":"AAIA,cAAM,oBAAoB;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoC;IAEpD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;IACjC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAO;IAChC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAO;IACvC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAO;IACrC,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAO;IAExC,sBAAsB,SAA2C;IACjE,YAAY,SAA0D;IAG7E,OAAO;WAEO,mBAAmB;IAQ1B,oBAAoB;IAapB,MAAM,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;QAAC,OAAO,EAAE;YAAE,IAAI,EAAE,IAAI,CAAC;YAAC,UAAU,EAAE,IAAI,CAAC;YAAC,iBAAiB,EAAE,IAAI,CAAC;YAAC,WAAW,EAAE,IAAI,CAAC;SAAE,CAAC;KAAE;IAYzH,KAAK;CAef;;AAED,wBAAyD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 path_1 = __importDefault(require("path"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
class AccessibilityScripts {
|
|
10
|
+
// don't allow to create instances from it other than through `checkAndGetInstance`
|
|
11
|
+
constructor() {
|
|
12
|
+
this.performScan = null;
|
|
13
|
+
this.getResults = null;
|
|
14
|
+
this.getResultsSummary = null;
|
|
15
|
+
this.saveTestResults = null;
|
|
16
|
+
this.commandsToWrap = null;
|
|
17
|
+
this.browserstackFolderPath = path_1.default.join(os_1.default.homedir(), '.browserstack');
|
|
18
|
+
this.commandsPath = path_1.default.join(this.browserstackFolderPath, 'commands.json');
|
|
19
|
+
}
|
|
20
|
+
static checkAndGetInstance() {
|
|
21
|
+
if (!AccessibilityScripts.instance) {
|
|
22
|
+
AccessibilityScripts.instance = new AccessibilityScripts();
|
|
23
|
+
AccessibilityScripts.instance.readFromExistingFile();
|
|
24
|
+
}
|
|
25
|
+
return AccessibilityScripts.instance;
|
|
26
|
+
}
|
|
27
|
+
readFromExistingFile() {
|
|
28
|
+
try {
|
|
29
|
+
if (fs_1.default.existsSync(this.commandsPath)) {
|
|
30
|
+
const data = fs_1.default.readFileSync(this.commandsPath, 'utf8');
|
|
31
|
+
if (data) {
|
|
32
|
+
this.update(JSON.parse(data));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
/* Do nothing */
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
update(data) {
|
|
41
|
+
if (data.scripts) {
|
|
42
|
+
this.performScan = data.scripts.scan;
|
|
43
|
+
this.getResults = data.scripts.getResults;
|
|
44
|
+
this.getResultsSummary = data.scripts.getResultsSummary;
|
|
45
|
+
this.saveTestResults = data.scripts.saveResults;
|
|
46
|
+
}
|
|
47
|
+
if (data.commands && data.commands.length) {
|
|
48
|
+
this.commandsToWrap = data.commands;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
store() {
|
|
52
|
+
if (!fs_1.default.existsSync(this.browserstackFolderPath)) {
|
|
53
|
+
fs_1.default.mkdirSync(this.browserstackFolderPath);
|
|
54
|
+
}
|
|
55
|
+
fs_1.default.writeFileSync(this.commandsPath, JSON.stringify({
|
|
56
|
+
commands: this.commandsToWrap,
|
|
57
|
+
scripts: {
|
|
58
|
+
scan: this.performScan,
|
|
59
|
+
getResults: this.getResults,
|
|
60
|
+
getResultsSummary: this.getResultsSummary,
|
|
61
|
+
saveResults: this.saveTestResults,
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
AccessibilityScripts.instance = null;
|
|
67
|
+
exports.default = AccessibilityScripts.checkAndGetInstance();
|
package/build/service.d.ts
CHANGED
package/build/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAA8C,MAAM,SAAS,CAAA;AAKhH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"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"}
|
package/build/service.js
CHANGED
|
@@ -13,6 +13,9 @@ const reporter_1 = __importDefault(require("./reporter"));
|
|
|
13
13
|
const performance_tester_1 = __importDefault(require("./performance-tester"));
|
|
14
14
|
const accessibility_handler_1 = __importDefault(require("./accessibility-handler"));
|
|
15
15
|
const Percy_Handler_1 = __importDefault(require("./Percy/Percy-Handler"));
|
|
16
|
+
const listener_1 = __importDefault(require("./testOps/listener"));
|
|
17
|
+
const data_store_1 = require("./data-store");
|
|
18
|
+
const usageStats_1 = __importDefault(require("./testOps/usageStats"));
|
|
16
19
|
const log = (0, logger_1.default)('@wdio/browserstack-service');
|
|
17
20
|
class BrowserstackService {
|
|
18
21
|
constructor(options, _caps, _config) {
|
|
@@ -33,7 +36,7 @@ class BrowserstackService {
|
|
|
33
36
|
this._turboScale = this._options.turboScale;
|
|
34
37
|
if (this._observability) {
|
|
35
38
|
(_a = this._config.reporters) === null || _a === void 0 ? void 0 : _a.push(reporter_1.default);
|
|
36
|
-
if (process.env.
|
|
39
|
+
if (process.env[constants_1.PERF_MEASUREMENT_ENV]) {
|
|
37
40
|
performance_tester_1.default.startMonitoring('performance-report-service.csv');
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -90,9 +93,18 @@ class BrowserstackService {
|
|
|
90
93
|
try {
|
|
91
94
|
if (this._observability) {
|
|
92
95
|
(0, util_1.patchConsoleLogs)();
|
|
93
|
-
this._insightsHandler = new insights_handler_1.default(this._browser, this._browser.capabilities, this._isAppAutomate(), this._browser.sessionId, this._config.framework);
|
|
96
|
+
this._insightsHandler = new insights_handler_1.default(this._browser, this._browser.capabilities, this._isAppAutomate(), this._browser.sessionId, this._config.framework, this._caps);
|
|
94
97
|
await this._insightsHandler.before();
|
|
95
98
|
}
|
|
99
|
+
if (this._browser && (0, util_1.isBrowserstackSession)(this._browser)) {
|
|
100
|
+
try {
|
|
101
|
+
this._accessibilityHandler = new accessibility_handler_1.default(this._browser, this._caps, this._isAppAutomate(), this._config.framework, this._accessibility, this._options.accessibilityOptions);
|
|
102
|
+
await this._accessibilityHandler.before(this._browser.sessionId);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
log.error(`[Accessibility Test Run] Error in service class before function: ${err}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
96
108
|
/**
|
|
97
109
|
* register command event
|
|
98
110
|
*/
|
|
@@ -121,15 +133,6 @@ class BrowserstackService {
|
|
|
121
133
|
}
|
|
122
134
|
}
|
|
123
135
|
}
|
|
124
|
-
if (this._browser && (0, util_1.isBrowserstackSession)(this._browser)) {
|
|
125
|
-
try {
|
|
126
|
-
this._accessibilityHandler = new accessibility_handler_1.default(this._browser, this._caps, this._isAppAutomate(), this._config.framework, this._accessibility, this._options.accessibilityOptions);
|
|
127
|
-
await this._accessibilityHandler.before();
|
|
128
|
-
}
|
|
129
|
-
catch (err) {
|
|
130
|
-
log.error(`[Accessibility Test Run] Error in service class before function: ${err}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
136
|
return await this._printSessionURL();
|
|
134
137
|
}
|
|
135
138
|
/**
|
|
@@ -189,7 +192,7 @@ class BrowserstackService {
|
|
|
189
192
|
await ((_c = this._accessibilityHandler) === null || _c === void 0 ? void 0 : _c.afterTest(this._suiteTitle, test));
|
|
190
193
|
}
|
|
191
194
|
async after(result) {
|
|
192
|
-
var _a
|
|
195
|
+
var _a;
|
|
193
196
|
const { preferScenarioName, setSessionName, setSessionStatus } = this._options;
|
|
194
197
|
// For Cucumber: Checks scenarios that ran (i.e. not skipped) on the session
|
|
195
198
|
// Only 1 Scenario ran and option enabled => Redefine session name to Scenario's name
|
|
@@ -204,10 +207,10 @@ class BrowserstackService {
|
|
|
204
207
|
...(hasReasons ? { reason: this._failReasons.join('\n') } : {})
|
|
205
208
|
});
|
|
206
209
|
}
|
|
207
|
-
await (
|
|
208
|
-
await ((
|
|
209
|
-
|
|
210
|
-
if (process.env.
|
|
210
|
+
await listener_1.default.getInstance().onWorkerEnd();
|
|
211
|
+
await ((_a = this._percyHandler) === null || _a === void 0 ? void 0 : _a.teardown());
|
|
212
|
+
this.saveWorkerData();
|
|
213
|
+
if (process.env[constants_1.PERF_MEASUREMENT_ENV]) {
|
|
211
214
|
await performance_tester_1.default.stopAndGenerate('performance-service.html');
|
|
212
215
|
performance_tester_1.default.calculateTimes([
|
|
213
216
|
'onRunnerStart', 'onSuiteStart', 'onSuiteEnd',
|
|
@@ -408,5 +411,10 @@ class BrowserstackService {
|
|
|
408
411
|
}
|
|
409
412
|
return (await this._browser.execute(script));
|
|
410
413
|
}
|
|
414
|
+
saveWorkerData() {
|
|
415
|
+
(0, data_store_1.saveWorkerData)({
|
|
416
|
+
usageStats: usageStats_1.default.getInstance().getDataToSave()
|
|
417
|
+
});
|
|
418
|
+
}
|
|
411
419
|
}
|
|
412
420
|
exports.default = BrowserstackService;
|