@testim/testim-cli 3.245.0 → 3.246.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/chromiumInstaller.js +92 -0
- package/cli.js +89 -87
- package/cliAgentMode.js +39 -114
- package/commons/getSessionPlayerRequire.js +2 -1
- package/commons/prepareRunner.js +2 -0
- package/commons/testimServicesApi.js +5 -0
- package/npm-shrinkwrap.json +135 -98
- package/package.json +1 -1
- package/player/WebDriverHttpRequest.js +45 -37
- package/player/chromeLauncherTestPlayer.js +2 -2
- package/player/services/playbackTimeoutCalculator.js +5 -1
- package/player/stepActions/sfdcStepAction.js +27 -0
- package/player/stepActions/stepActionRegistrar.js +12 -0
- package/player/webdriver.js +51 -52
- package/runOptions.js +3 -1
- package/runner.js +44 -41
- package/testRunHandler.js +4 -1
- package/utils.js +42 -2
- package/utils.test.js +26 -0
package/utils.js
CHANGED
|
@@ -10,6 +10,10 @@ const { sessionType, testStatus: testStatusConst } = require('./commons/constant
|
|
|
10
10
|
const path = require('path');
|
|
11
11
|
const httpRequest = require('./commons/httpRequest');
|
|
12
12
|
const decompress = require('decompress');
|
|
13
|
+
const os = require('os');
|
|
14
|
+
|
|
15
|
+
const HOMEDIR = os.homedir();
|
|
16
|
+
const TESTIM_BROWSER_DIR = path.join(HOMEDIR, '.testim-browser-profile');
|
|
13
17
|
|
|
14
18
|
const OSS = [
|
|
15
19
|
{ osName: 'Linux', bs: { os: 'LINUX' }, sl: { platform: 'Linux' } },
|
|
@@ -183,7 +187,7 @@ function extractElementId(element) {
|
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
function isURL(path) {
|
|
186
|
-
const legacyPattern =
|
|
190
|
+
const legacyPattern = /^(https?:\/\/)/i;
|
|
187
191
|
|
|
188
192
|
// https://gist.github.com/dperini/729294 (validator.js based on).
|
|
189
193
|
const pattern = new RegExp(
|
|
@@ -304,7 +308,7 @@ function getPlanType(plan) {
|
|
|
304
308
|
* @param time {number} in ms
|
|
305
309
|
* @returns {Promise}
|
|
306
310
|
*/
|
|
307
|
-
|
|
311
|
+
function delay(time) {
|
|
308
312
|
return new Promise(((resolve) => {
|
|
309
313
|
setTimeout(resolve, time);
|
|
310
314
|
}));
|
|
@@ -356,7 +360,41 @@ function groupTestsByRetries(testResults = []) { // NOTE: This duplicates a func
|
|
|
356
360
|
.value();
|
|
357
361
|
}
|
|
358
362
|
|
|
363
|
+
async function getCdpAddressForHost(browserInstanceHost, timeout) {
|
|
364
|
+
try {
|
|
365
|
+
/**
|
|
366
|
+
Example response:
|
|
367
|
+
{
|
|
368
|
+
"Browser": "Chrome/81.0.4044.138",
|
|
369
|
+
"Protocol-Version": "1.3",
|
|
370
|
+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
|
|
371
|
+
"V8-Version": "8.1.307.32",
|
|
372
|
+
"WebKit-Version": "537.36 (@8c6c7ba89cc9453625af54f11fd83179e23450fa)",
|
|
373
|
+
"webSocketDebuggerUrl": "ws://localhost:58938/devtools/browser/d4290379-ec08-4d03-a41a-ab9d9d4c36ac"
|
|
374
|
+
}
|
|
375
|
+
*/
|
|
376
|
+
const debuggerAddress = await httpRequest.get(`http://${browserInstanceHost}/json/version`, undefined, undefined, timeout);
|
|
377
|
+
return debuggerAddress.webSocketDebuggerUrl;
|
|
378
|
+
} catch (e) {
|
|
379
|
+
throw new Error('unable to connect to devtools server');
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function getArgsOnRemoteRunFailure() {
|
|
384
|
+
const { argv: args } = process;
|
|
385
|
+
if (!args.includes('--remoteRunId')) {
|
|
386
|
+
return undefined;
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
remoteRunId: args[args.indexOf('--remoteRunId') + 1],
|
|
390
|
+
projectId: args[args.indexOf('--project') + 1],
|
|
391
|
+
token: args[args.indexOf('--token') + 1],
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
|
|
359
396
|
module.exports = {
|
|
397
|
+
TESTIM_BROWSER_DIR,
|
|
360
398
|
removePropertyFromObject,
|
|
361
399
|
getTestUrl,
|
|
362
400
|
getDuration,
|
|
@@ -390,4 +428,6 @@ module.exports = {
|
|
|
390
428
|
groupTestsByRetries,
|
|
391
429
|
getPlanType,
|
|
392
430
|
delay,
|
|
431
|
+
getCdpAddressForHost,
|
|
432
|
+
getArgsOnRemoteRunFailure,
|
|
393
433
|
};
|
package/utils.test.js
CHANGED
|
@@ -39,4 +39,30 @@ describe('utils', () => {
|
|
|
39
39
|
.to.equal('http://localhost:8080/#/project/project/branch/encoded%2520branch/test/test?result-id=result');
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
|
+
|
|
43
|
+
describe('getArgsOnRemoteRunFailure', () => {
|
|
44
|
+
let originalArgv;
|
|
45
|
+
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
originalArgv = process.argv;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
process.argv = originalArgv;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should return undefined if no remote run is current', () => {
|
|
55
|
+
process.argv = ['node', 'file.js', '--token', 'token', '--project', 'project-id'];
|
|
56
|
+
expect(utils.getArgsOnRemoteRunFailure()).to.be.undefined;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should return details if remote run is current', () => {
|
|
60
|
+
process.argv = ['node', 'file.js', '--token', 'token', '--project', 'project-id', '--remoteRunId', 'remote-run-id'];
|
|
61
|
+
expect(utils.getArgsOnRemoteRunFailure()).to.eql({
|
|
62
|
+
remoteRunId: 'remote-run-id',
|
|
63
|
+
projectId: 'project-id',
|
|
64
|
+
token: 'token',
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
42
68
|
});
|