@testim/testim-cli 3.270.0 → 3.271.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/agent/routers/cliJsCode/service.js +6 -8
- package/agent/server.js +3 -3
- package/cdpTestRunner.js +0 -2
- package/commons/httpRequestCounters.js +6 -5
- package/commons/npmWrapper.js +2 -2
- package/commons/prepareRunner.js +1 -3
- package/commons/runnerFileCache.js +3 -3
- package/commons/socket/baseSocketServiceSocketIO.js +0 -1
- package/commons/socket/remoteStepService.js +3 -4
- package/commons/socket/remoteStepServiceSocketIO.js +0 -1
- package/commons/socket/socketService.js +6 -6
- package/commons/socket/testResultServiceSocketIO.js +0 -1
- package/commons/testimCustomToken.js +1 -1
- package/commons/testimServicesApi.js +2 -3
- package/coverage/jsCoverage.js +0 -1
- package/credentialsManager.js +7 -6
- package/npm-shrinkwrap.json +83 -145
- package/package.json +2 -2
- package/player/WebdriverioWebDriverApi.js +12 -11
- package/player/seleniumTestPlayer.js +0 -1
- package/player/services/frameLocator.js +69 -36
- package/player/services/portSelector.js +0 -2
- package/player/services/tabService.js +4 -2
- package/player/stepActions/RefreshStepAction.js +0 -1
- package/player/stepActions/baseJsStepAction.js +0 -1
- package/player/stepActions/locateStepAction.js +0 -1
- package/player/stepActions/specialKeyStepAction.js +0 -1
- package/player/utils/screenshotUtils.js +0 -1
- package/player/utils/windowUtils.js +0 -1
- package/runners/buildCodeTests.js +0 -1
- package/services/gridService.js +33 -25
- package/testRunHandler.js +5 -1
- package/workers/WorkerSelenium.js +64 -49
- package/workers/workerUtils.js +9 -7
|
@@ -6,7 +6,6 @@ const path = require('path');
|
|
|
6
6
|
const os = require('os');
|
|
7
7
|
const dataUriToBuffer = require('data-uri-to-buffer');
|
|
8
8
|
const { spawn: threadSpawn, config } = require('threads');
|
|
9
|
-
const Promise = require('bluebird');
|
|
10
9
|
const fse = require('fs-extra');
|
|
11
10
|
const fs = require('fs');
|
|
12
11
|
const utils = require('../../../utils');
|
|
@@ -564,13 +563,12 @@ function runCodeWithWorkerThread(
|
|
|
564
563
|
.finally(() => thread?.terminate());
|
|
565
564
|
}
|
|
566
565
|
|
|
567
|
-
function removeFolder(installFolder) {
|
|
568
|
-
|
|
569
|
-
.
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}));
|
|
566
|
+
async function removeFolder(installFolder) {
|
|
567
|
+
try {
|
|
568
|
+
await fse.remove(installFolder);
|
|
569
|
+
} catch (err) {
|
|
570
|
+
logger.warn('failed to remove install npm packages folder', { err });
|
|
571
|
+
}
|
|
574
572
|
}
|
|
575
573
|
|
|
576
574
|
function getTransactionId(stepResultId, testResultId, stepId, retryIndex) {
|
package/agent/server.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const Promise = require('bluebird');
|
|
4
3
|
const { ArgError } = require('../errors');
|
|
5
4
|
const testimCustomToken = require('../commons/testimCustomToken');
|
|
6
5
|
const lazyRequire = require('../commons/lazyRequire');
|
|
@@ -111,6 +110,7 @@ function initServer({
|
|
|
111
110
|
|
|
112
111
|
function onListening() {
|
|
113
112
|
const { port } = server.address();
|
|
113
|
+
// eslint-disable-next-line no-console
|
|
114
114
|
console.log(`Running on port: ${port}`);
|
|
115
115
|
showStartStopOptions();
|
|
116
116
|
}
|
|
@@ -128,8 +128,7 @@ function installExternalPackages({ installPlaygroundPlaywrightDeps, installPlayg
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
if (installPlaygroundSeleniumDeps) {
|
|
131
|
-
all.push(lazyRequire('selenium-webdriver'));
|
|
132
|
-
all.push(prepareChromeDriver({ projectId: project }));
|
|
131
|
+
all.push(lazyRequire('selenium-webdriver'), prepareChromeDriver({ projectId: project }));
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
return Promise.all(all);
|
|
@@ -145,6 +144,7 @@ async function showStartStopOptions() {
|
|
|
145
144
|
message: `Type the word "stop" or Press ${sigint}.`,
|
|
146
145
|
validate: x => x.toUpperCase().trim() === 'STOP',
|
|
147
146
|
});
|
|
147
|
+
// eslint-disable-next-line no-console
|
|
148
148
|
console.log('Exiting Testim CLI');
|
|
149
149
|
process.exit(0);
|
|
150
150
|
}
|
package/cdpTestRunner.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
'use strict';
|
|
2
4
|
|
|
3
5
|
const _ = require('lodash');
|
|
4
6
|
const config = require('./config');
|
|
5
7
|
const dns = require('dns').promises;
|
|
6
|
-
const Bluebird = require('bluebird');
|
|
7
8
|
const { sum } = require('lodash');
|
|
8
9
|
const { promiseMap } = require('../utils/promiseUtils');
|
|
9
10
|
|
|
@@ -59,12 +60,12 @@ module.exports.makeCounters = () => {
|
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
61
62
|
* @template T, TArgs
|
|
62
|
-
* @param {(...args: TArgs) => T} fn
|
|
63
|
+
* @param {(...args: TArgs[]) => T} fn
|
|
63
64
|
* @param {string=} name
|
|
64
|
-
* @return {(...args: TArgs) =>
|
|
65
|
+
* @return {(...args: TArgs[]) => Promise<Awaited<T>>}
|
|
65
66
|
*/
|
|
66
67
|
function wrapWithMonitoring(fn, name = fn.name) {
|
|
67
|
-
return
|
|
68
|
+
return async function (...args) {
|
|
68
69
|
update(counters.call, name);
|
|
69
70
|
try {
|
|
70
71
|
const result = await fn.call(this, ...args);
|
|
@@ -77,7 +78,7 @@ module.exports.makeCounters = () => {
|
|
|
77
78
|
}
|
|
78
79
|
throw e;
|
|
79
80
|
}
|
|
80
|
-
}
|
|
81
|
+
};
|
|
81
82
|
}
|
|
82
83
|
wrapWithMonitoring.isNetworkHealthy = async function isNetworkHealthy() {
|
|
83
84
|
if (networkConnectivityTestFailed || !(await testNetworkConnectivity())) {
|
package/commons/npmWrapper.js
CHANGED
|
@@ -5,11 +5,11 @@ const exec = util.promisify(require('child_process').exec);
|
|
|
5
5
|
const spawn = require('child_process').spawn;
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const { NpmPackageError, NpmPermissionsError } = require('../errors');
|
|
8
|
-
const Promise = require('bluebird');
|
|
9
8
|
const fse = require('fs-extra');
|
|
10
9
|
const logger = require('./logger').getLogger('cli-service');
|
|
11
10
|
const { requireWithFallback } = require('./requireWithFallback');
|
|
12
11
|
const fs = require('fs');
|
|
12
|
+
const utils = require('../utils');
|
|
13
13
|
|
|
14
14
|
async function getLatestPackageVersion(packageName) {
|
|
15
15
|
const result = await exec(`npm view ${packageName} version`);
|
|
@@ -157,7 +157,7 @@ function installPackages(prefix, packageNames, proxyUri, timeoutMs) {
|
|
|
157
157
|
try {
|
|
158
158
|
npmInstall.kill();
|
|
159
159
|
} finally {
|
|
160
|
-
reject(new
|
|
160
|
+
reject(new utils.TimeoutError());
|
|
161
161
|
}
|
|
162
162
|
}, timeoutMs);
|
|
163
163
|
});
|
package/commons/prepareRunner.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { CLI_MODE } = require('./constants');
|
|
4
4
|
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const Promise = require('bluebird');
|
|
7
5
|
const os = require('os');
|
|
8
6
|
const utils = require('../utils');
|
|
9
7
|
const Ajv = require('ajv');
|
|
@@ -20,7 +18,7 @@ const logger = require('./logger').getLogger('prepare runner');
|
|
|
20
18
|
/** @param {import('../runOptions').RunnerOptions} options */
|
|
21
19
|
async function prepare(options) {
|
|
22
20
|
/**
|
|
23
|
-
* @type {
|
|
21
|
+
* @type {Promise<void>}
|
|
24
22
|
*/
|
|
25
23
|
let chromedriverPromise = Promise.resolve();
|
|
26
24
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
const path = require('path');
|
|
6
|
-
const Promise = require('bluebird');
|
|
7
6
|
const debounce = require('lodash/debounce');
|
|
8
7
|
const fs = require('fs');
|
|
9
8
|
const { getCliLocation } = require('../utils');
|
|
@@ -102,7 +101,7 @@ function decrypt(key, buffer) {
|
|
|
102
101
|
* @returns {() => Promise<Awaited<T>>}
|
|
103
102
|
*/
|
|
104
103
|
function memoize(fn, fnName, duration = THREE_HOURS, parameters = undefined) {
|
|
105
|
-
return
|
|
104
|
+
return async () => {
|
|
106
105
|
if (!cacheEnabled) {
|
|
107
106
|
return await fn();
|
|
108
107
|
}
|
|
@@ -124,8 +123,9 @@ function memoize(fn, fnName, duration = THREE_HOURS, parameters = undefined) {
|
|
|
124
123
|
await set(fnName, value, duration);
|
|
125
124
|
}
|
|
126
125
|
return value;
|
|
127
|
-
}
|
|
126
|
+
};
|
|
128
127
|
}
|
|
128
|
+
|
|
129
129
|
async function get(key) {
|
|
130
130
|
const obj = await localRunnerCache;
|
|
131
131
|
const valueExpiry = obj[key];
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
let remoteStepServiceSocketIO; // required lazily since it takes 150ms to load
|
|
2
1
|
const socketService = require('./socketService');
|
|
3
|
-
|
|
4
2
|
const { socketEventTypes } = require('../constants');
|
|
3
|
+
const featureFlags = require('../featureFlags');
|
|
5
4
|
|
|
6
5
|
const { REMOTE_STEP_SAVED } = socketEventTypes;
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
let remoteStepServiceSocketIO; // required lazily since it takes 150ms to load
|
|
9
8
|
|
|
10
9
|
class RemoteStepService {
|
|
11
10
|
init(projectId) {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const WebSocket = require('ws');
|
|
4
|
+
const _ = require('lodash');
|
|
4
5
|
const { WEBSOCKET_HOST } = require('../config');
|
|
5
6
|
const utils = require('../../utils');
|
|
6
7
|
const logger = require('../logger').getLogger('socket-ng-service');
|
|
7
8
|
const { EventEmitter } = require('events');
|
|
8
|
-
const _ = require('lodash');
|
|
9
|
-
const Promise = require('bluebird');
|
|
10
9
|
const testimCustomToken = require('../testimCustomToken');
|
|
11
10
|
|
|
12
11
|
const WAIT_BETWEEN_RECONNECT_MS = 5000;
|
|
@@ -25,13 +24,14 @@ class SocketService extends EventEmitter {
|
|
|
25
24
|
setTimeout(() => this.connect(projectId), WAIT_BETWEEN_RECONNECT_MS);
|
|
26
25
|
}
|
|
27
26
|
|
|
27
|
+
/** @param {string} url */
|
|
28
28
|
formatUrl(url) {
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
29
|
+
if (url.startsWith('http://')) {
|
|
30
|
+
return url.replace('http://', 'ws://');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
33
|
+
if (url.startsWith('https://')) {
|
|
34
|
+
return url.replace('https://', 'wss://');
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return url;
|
|
@@ -5,7 +5,6 @@ const pRetry = require('p-retry');
|
|
|
5
5
|
const _ = require('lodash');
|
|
6
6
|
const testimCustomToken = require('./testimCustomToken');
|
|
7
7
|
const constants = require('./constants');
|
|
8
|
-
const Promise = require('bluebird');
|
|
9
8
|
const utils = require('../utils');
|
|
10
9
|
const config = require('./config');
|
|
11
10
|
const httpRequest = require('./httpRequest');
|
|
@@ -298,7 +297,7 @@ function getGridById(companyId, projectId, gridId, browser, executionId) {
|
|
|
298
297
|
|
|
299
298
|
/**
|
|
300
299
|
* @param {{ projectId: string; token: string; branchName: string; lightweightMode?: import('../runOptions').LightweightSettings; localGrid: boolean; }} param0
|
|
301
|
-
* @returns {
|
|
300
|
+
* @returns {Promise<{
|
|
302
301
|
* authData: { token: string; refreshToken: string; uid: string; ngrokToken?: string; isNgrokWhitelisted?: boolean; };
|
|
303
302
|
* editorConfig: { editorUrl: string };
|
|
304
303
|
* companyByProjectId: Awaited<ReturnType<import('services/src/company/companyService')['getCompanyByProjectIdUsingCache']>>;
|
|
@@ -580,7 +579,7 @@ module.exports = {
|
|
|
580
579
|
getEditorUrl,
|
|
581
580
|
getLabFeaturesByProjectId,
|
|
582
581
|
uploadRunDataArtifact,
|
|
583
|
-
updateTestDataArtifact
|
|
582
|
+
updateTestDataArtifact,
|
|
584
583
|
initializeUserWithAuth,
|
|
585
584
|
addTestRetry,
|
|
586
585
|
getHybridGridProvider,
|
package/coverage/jsCoverage.js
CHANGED
package/credentialsManager.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const fse = require('fs-extra');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const Promise = require('bluebird');
|
|
6
5
|
const YAML = require('yaml');
|
|
7
6
|
const os = require('os');
|
|
8
7
|
const utils = require('./utils');
|
|
@@ -24,10 +23,12 @@ function timeout(promise, ms) {
|
|
|
24
23
|
async function getCredentialsFromChrome() {
|
|
25
24
|
const app = require('express')();
|
|
26
25
|
const loginInfoFromChrome = (async function waitForChromeToSendData() {
|
|
27
|
-
return timeout(new Promise(resolve =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
return timeout(new Promise(resolve => {
|
|
27
|
+
app.get('/loginInfo', (req, res) => {
|
|
28
|
+
resolve(JSON.parse(Buffer.from(req.query.info, 'base64').toString()));
|
|
29
|
+
res.status(200).end();
|
|
30
|
+
});
|
|
31
|
+
}), 60000).catch(() => null);
|
|
31
32
|
}());
|
|
32
33
|
await new Promise((resolve, reject) => {
|
|
33
34
|
const server = app.listen(42543, (err) => {
|
|
@@ -71,7 +72,7 @@ async function doLogin({ overwriteExisting = true, projects = null } = {}) {
|
|
|
71
72
|
const spinner = ora('Getting credentials from Testim extension ...').start();
|
|
72
73
|
|
|
73
74
|
if (!projects) {
|
|
74
|
-
projects = await timeout(Promise.resolve(getCredentialsFromChrome()), 62000).catch(
|
|
75
|
+
projects = await timeout(Promise.resolve(getCredentialsFromChrome()), 62000).catch(() => null);
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
if (projects?.token) { // V1(legacy) of the login extension API
|