@testim/testim-cli 3.269.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.
Files changed (39) hide show
  1. package/agent/routers/cliJsCode/service.js +6 -8
  2. package/agent/server.js +3 -3
  3. package/cdpTestRunner.js +0 -2
  4. package/cliAgentMode.js +0 -10
  5. package/commons/httpRequestCounters.js +6 -5
  6. package/commons/npmWrapper.js +2 -2
  7. package/commons/prepareRunner.js +1 -8
  8. package/commons/runnerFileCache.js +3 -3
  9. package/commons/socket/baseSocketServiceSocketIO.js +0 -1
  10. package/commons/socket/remoteStepService.js +3 -4
  11. package/commons/socket/remoteStepServiceSocketIO.js +0 -1
  12. package/commons/socket/socketService.js +6 -6
  13. package/commons/socket/testResultServiceSocketIO.js +0 -1
  14. package/commons/testimCustomToken.js +1 -1
  15. package/commons/testimDesiredCapabilitiesBuilder.js +1 -0
  16. package/commons/testimServicesApi.js +4 -5
  17. package/coverage/jsCoverage.js +0 -1
  18. package/credentialsManager.js +7 -6
  19. package/npm-shrinkwrap.json +107 -169
  20. package/package.json +2 -2
  21. package/player/WebdriverioWebDriverApi.js +12 -11
  22. package/player/seleniumTestPlayer.js +0 -1
  23. package/player/services/frameLocator.js +69 -36
  24. package/player/services/portSelector.js +0 -2
  25. package/player/services/tabService.js +4 -2
  26. package/player/stepActions/RefreshStepAction.js +0 -1
  27. package/player/stepActions/baseJsStepAction.js +0 -1
  28. package/player/stepActions/locateStepAction.js +0 -1
  29. package/player/stepActions/specialKeyStepAction.js +0 -1
  30. package/player/utils/screenshotUtils.js +0 -1
  31. package/player/utils/windowUtils.js +0 -1
  32. package/polyfills/index.js +4 -0
  33. package/runners/TestPlanRunner.js +1 -1
  34. package/runners/buildCodeTests.js +0 -1
  35. package/runners/runnerUtils.js +0 -1
  36. package/services/gridService.js +33 -25
  37. package/testRunHandler.js +5 -1
  38. package/workers/WorkerSelenium.js +64 -49
  39. 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
- return new Promise(resolve => fse.remove(installFolder)
569
- .then(resolve)
570
- .catch(err => {
571
- logger.warn('failed to remove install npm packages folder', { err });
572
- return resolve();
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,8 +1,6 @@
1
1
  const WebSocket = require('ws');
2
- const Promise = require('bluebird');
3
2
  const { promiseFromCallback } = require('./utils');
4
3
 
5
-
6
4
  class CDPTestRunner {
7
5
  constructor() {
8
6
  this._cdpUrl = null;
package/cliAgentMode.js CHANGED
@@ -90,15 +90,6 @@ async function runAgentMode(options) {
90
90
  );
91
91
  }
92
92
 
93
- async function hackForCoralogixAndXhr() {
94
- Promise.resolve().then(() => {
95
- // @ts-ignore
96
- global.xhr2 = require('./commons/xhr2'); // this is inside a `then` to not block and let network requests start
97
- });
98
-
99
- // this gets picked up later in sessionPlayerInit
100
- }
101
-
102
93
  let startedWithStart = false;
103
94
 
104
95
  function getStartedWithStart() {
@@ -179,7 +170,6 @@ async function startTestimStandaloneBrowser(options) {
179
170
 
180
171
  let shouldDownloadExtension = !(options.ext || options.extensionPath);
181
172
 
182
- await hackForCoralogixAndXhr();
183
173
  if (shouldDownloadExtension && await fs.pathExists(downloadedExtensionPath)) {
184
174
  const stat = await fs.stat(downloadedExtensionPath);
185
175
  shouldDownloadExtension = (Date.now() - EXTENSION_CACHE_TIME > stat.mtimeMs);
@@ -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) => Bluebird<Awaited<T>>}
65
+ * @return {(...args: TArgs[]) => Promise<Awaited<T>>}
65
66
  */
66
67
  function wrapWithMonitoring(fn, name = fn.name) {
67
- return Bluebird.method(async function (...args) {
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())) {
@@ -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 Promise.TimeoutError());
160
+ reject(new utils.TimeoutError());
161
161
  }
162
162
  }, timeoutMs);
163
163
  });
@@ -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');
@@ -17,15 +15,10 @@ const PREPARE_MOCK_NETWORK_ERROR_PREFIX = 'JSON file supplied to --mock-network-
17
15
 
18
16
  const logger = require('./logger').getLogger('prepare runner');
19
17
 
20
- Promise.resolve().then(() => {
21
- // @ts-ignore
22
- global.xhr2 = require('./xhr2'); // this is inside a `then` to not block and let network requests start
23
- });
24
-
25
18
  /** @param {import('../runOptions').RunnerOptions} options */
26
19
  async function prepare(options) {
27
20
  /**
28
- * @type {globalThis.Promise<void>}
21
+ * @type {Promise<void>}
29
22
  */
30
23
  let chromedriverPromise = Promise.resolve();
31
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 Promise.method(async () => {
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,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const Promise = require('bluebird');
4
3
  const pRetry = require('p-retry');
5
4
  const io = require('socket.io-client');
6
5
  const config = require('../config');
@@ -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
- const featureFlags = require('../featureFlags');
8
- const Promise = require('bluebird');
6
+
7
+ let remoteStepServiceSocketIO; // required lazily since it takes 150ms to load
9
8
 
10
9
  class RemoteStepService {
11
10
  init(projectId) {
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const Promise = require('bluebird');
4
3
  const BaseSocketService = require('./baseSocketServiceSocketIO');
5
4
 
6
5
  class RemoteStepServiceSocketIO extends BaseSocketService {
@@ -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 (_.startsWith(url, 'http://')) {
30
- return _.replace(url, 'http://', 'ws://');
29
+ if (url.startsWith('http://')) {
30
+ return url.replace('http://', 'ws://');
31
31
  }
32
32
 
33
- if (_.startsWith(url, 'https://')) {
34
- return _.replace(url, 'https://', 'wss://');
33
+ if (url.startsWith('https://')) {
34
+ return url.replace('https://', 'wss://');
35
35
  }
36
36
 
37
37
  return url;
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const Promise = require('bluebird');
4
3
  const BaseSocketService = require('./baseSocketServiceSocketIO');
5
4
 
6
5
  class TestResultServiceSocketIO extends BaseSocketService {
@@ -119,7 +119,7 @@ function getTokenV3UserData() {
119
119
  }
120
120
 
121
121
  module.exports = {
122
- init: Promise.method(init),
122
+ init,
123
123
  initFromData,
124
124
  getCustomTokenV3,
125
125
  getTokenV3UserData,
@@ -582,6 +582,7 @@ function buildAppiumOptions({ projectType, gridInfo, testRunConfig, nativeApp, o
582
582
  let appCaps = {
583
583
  'headspin:capture': true,
584
584
  'appium:autoAcceptAlerts': true,
585
+ 'appium:noReset': true,
585
586
  };
586
587
  switch (projectType) {
587
588
  case 'ios':
@@ -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');
@@ -214,7 +213,7 @@ async function getTestPlanTestList(projectId, names, planIds, branch, intersecti
214
213
  * testConfigIds?: string[];
215
214
  * intersections: import('../runOptions').RunnerOptions['intersections'];
216
215
  * }} param0
217
- * @returns {import('services/src/suite/service').RunListResult}
216
+ * @returns {Promise<import('services/src/suite/service').RunListResult>}
218
217
  */
219
218
  function getSuiteTestList({
220
219
  projectId, labels, testIds, testNames, testConfigNames, suiteNames, suiteIds, branch, rerunFailedByRunId, testConfigIds, intersections,
@@ -234,7 +233,7 @@ function getSuiteTestList({
234
233
  testConfigIds,
235
234
  intersections,
236
235
  },
237
- }), { retries: DEFAULT_REQUEST_RETRY });
236
+ }), { retries: DEFAULT_REQUEST_RETRY, factor: 1 });
238
237
  }
239
238
 
240
239
  async function getAppDetails({ appId, projectId }) {
@@ -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 {globalThis.Promise<{
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: Promise.method(updateTestDataArtifact),
582
+ updateTestDataArtifact,
584
583
  initializeUserWithAuth,
585
584
  addTestRetry,
586
585
  getHybridGridProvider,
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const servicesApi = require('../commons/testimServicesApi');
4
- const Promise = require('bluebird');
5
4
  const fs = require('fs');
6
5
  const fsPromises = require('fs/promises');
7
6
  const path = require('path');
@@ -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 => app.get('/loginInfo', (req, res) => {
28
- resolve(JSON.parse(Buffer.from(req.query.info, 'base64').toString()));
29
- res.status(200).end();
30
- })), 60000).catch(() => null);
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(e => null);
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