@testim/testim-cli 3.253.0 → 3.255.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 (103) hide show
  1. package/OverrideTestDataBuilder.js +1 -1
  2. package/agent/routers/cliJsCode/index.js +4 -4
  3. package/agent/routers/cliJsCode/router.js +46 -42
  4. package/agent/routers/cliJsCode/service.js +18 -13
  5. package/agent/routers/codim/router.js +14 -17
  6. package/agent/routers/codim/router.test.js +19 -21
  7. package/agent/routers/codim/service.js +16 -16
  8. package/agent/routers/general/index.js +4 -8
  9. package/agent/routers/hybrid/registerRoutes.js +18 -18
  10. package/agent/routers/index.js +7 -7
  11. package/agent/routers/playground/router.js +11 -10
  12. package/agent/routers/playground/service.js +22 -23
  13. package/agent/routers/standalone-browser/registerRoutes.js +10 -10
  14. package/cdpTestRunner.js +4 -3
  15. package/chromiumInstaller.js +4 -5
  16. package/cli/onExit.js +2 -2
  17. package/cli.js +11 -10
  18. package/cliAgentMode.js +8 -8
  19. package/codim/codim-cli.js +20 -17
  20. package/codim/hybrid-utils.js +1 -1
  21. package/codim/measure-perf.js +9 -6
  22. package/codim/template.js/tests/examples/01-simple-text-validation.test.js +6 -6
  23. package/codim/template.js/tests/examples/02-using-locators.test.js +13 -15
  24. package/codim/template.js/tests/examples/03-using-hooks.test.js +17 -19
  25. package/codim/template.js/tests/examples/04-skip-and-only.test.js +16 -17
  26. package/codim/template.js/tests/examples/05-multiple-windows.test.js +16 -17
  27. package/codim/template.js/webpack.config.js +1 -1
  28. package/codim/template.ts/webpack.config.js +3 -3
  29. package/commons/AbortError.js +4 -4
  30. package/commons/detectDebugger.js +4 -2
  31. package/commons/featureFlags.js +8 -0
  32. package/commons/httpRequest.js +5 -1
  33. package/commons/httpRequestCounters.js +21 -10
  34. package/commons/lazyRequire.js +14 -12
  35. package/commons/logger.js +4 -4
  36. package/commons/performance-logger.js +14 -8
  37. package/commons/preloadTests.js +2 -2
  38. package/commons/prepareRunner.js +4 -2
  39. package/commons/prepareRunnerAndTestimStartUtils.js +40 -42
  40. package/commons/runnerFileCache.js +1 -1
  41. package/commons/socket/baseSocketServiceSocketIO.js +32 -34
  42. package/commons/socket/realDataService.js +6 -5
  43. package/commons/socket/realDataServiceSocketIO.js +4 -4
  44. package/commons/socket/remoteStepService.js +4 -3
  45. package/commons/socket/remoteStepServiceSocketIO.js +11 -12
  46. package/commons/socket/socketService.js +50 -52
  47. package/commons/socket/testResultServiceSocketIO.js +11 -11
  48. package/commons/testimDesiredCapabilitiesBuilder.js +3 -2
  49. package/commons/testimNgrok.js +2 -2
  50. package/commons/testimNgrok.test.js +1 -1
  51. package/commons/testimServicesApi.js +27 -20
  52. package/commons/testimTunnel.test.js +2 -1
  53. package/commons/xhr2.js +97 -100
  54. package/coverage/SummaryToObjectReport.js +0 -1
  55. package/coverage/jsCoverage.js +12 -10
  56. package/errors.js +5 -0
  57. package/fixLocalBuild.js +2 -0
  58. package/inputFileUtils.js +11 -9
  59. package/npm-shrinkwrap.json +2286 -1284
  60. package/package.json +9 -8
  61. package/player/appiumTestPlayer.js +1 -1
  62. package/player/chromeLauncherTestPlayer.js +0 -1
  63. package/player/services/tabService.js +15 -1
  64. package/player/services/tabServiceMock.js +166 -0
  65. package/player/stepActions/locateStepAction.js +2 -0
  66. package/player/stepActions/navigationStepAction.js +11 -10
  67. package/player/stepActions/sleepStepAction.js +4 -5
  68. package/player/stepActions/textStepAction.js +4 -11
  69. package/player/utils/imageCaptureUtils.js +81 -120
  70. package/player/utils/windowUtils.js +4 -3
  71. package/player/webdriver.js +26 -23
  72. package/processHandler.js +3 -3
  73. package/processHandler.test.js +1 -1
  74. package/reports/consoleReporter.js +3 -2
  75. package/reports/junitReporter.js +7 -9
  76. package/reports/reporter.js +34 -39
  77. package/runOptions.d.ts +260 -0
  78. package/runOptions.js +59 -44
  79. package/runner.js +14 -0
  80. package/runners/ParallelWorkerManager.js +9 -10
  81. package/runners/TestPlanRunner.js +142 -78
  82. package/runners/buildCodeTests.js +38 -37
  83. package/runners/runnerUtils.js +3 -3
  84. package/services/gridService.js +36 -40
  85. package/services/lambdatestService.js +3 -5
  86. package/stepPlayers/cliJsStepPlayback.js +22 -17
  87. package/testRunHandler.js +8 -0
  88. package/testRunStatus.js +9 -6
  89. package/utils/argsUtils.js +86 -0
  90. package/utils/argsUtils.test.js +32 -0
  91. package/utils/fsUtils.js +154 -0
  92. package/{utils.js → utils/index.js} +19 -262
  93. package/utils/promiseUtils.js +89 -0
  94. package/utils/stringUtils.js +98 -0
  95. package/utils/stringUtils.test.js +22 -0
  96. package/utils/timeUtils.js +25 -0
  97. package/utils/utils.test.js +27 -0
  98. package/workers/BaseWorker.js +16 -14
  99. package/workers/WorkerAppium.js +1 -1
  100. package/workers/WorkerExtension.js +6 -7
  101. package/workers/WorkerExtensionSingleBrowser.js +4 -4
  102. package/workers/WorkerSelenium.js +5 -2
  103. package/utils.test.js +0 -68
@@ -6,7 +6,7 @@ const _ = require('lodash');
6
6
  const testimCustomToken = require('./testimCustomToken');
7
7
  const constants = require('./constants');
8
8
  const Promise = require('bluebird');
9
- const utils = require('../utils.js');
9
+ const utils = require('../utils');
10
10
  const config = require('./config');
11
11
  const httpRequest = require('./httpRequest');
12
12
 
@@ -84,6 +84,12 @@ function getTestPlan(projectId, testPlanNames) {
84
84
  }));
85
85
  }
86
86
 
87
+ async function loadSfdcCredential({ branch, projectId }) {
88
+ const branchData = await pRetry(() => getWithAuth(`/branch/branchData/${branch}`, {
89
+ projectId,
90
+ }), { retries: DEFAULT_REQUEST_RETRY });
91
+ return branchData?.sfdcCredential;
92
+ }
87
93
 
88
94
  function loadTest({ testId, branch, projectId, skipSharedSteps = false, useBranchMap = true }) {
89
95
  return pRetry(() => getWithAuth(`/test/${testId}`, {
@@ -174,7 +180,7 @@ function reportExecutionFinished(status, executionId, projectId, success, tmsOpt
174
180
  tmsOptions,
175
181
  remoteRunId,
176
182
  resultExtraData,
177
- }), { reties: DEFAULT_REQUEST_RETRY });
183
+ }), { retries: DEFAULT_REQUEST_RETRY });
178
184
  }
179
185
 
180
186
  async function getTestPlanTestList(projectId, names, planIds, branch, intersections) {
@@ -183,7 +189,7 @@ async function getTestPlanTestList(projectId, names, planIds, branch, intersecti
183
189
  body: { projectId, names, planIds, branch, intersections },
184
190
  // people who send insane lists get a timeout :(
185
191
  timeout: 120000,
186
- }), { reties: DEFAULT_REQUEST_RETRY });
192
+ }), { retries: DEFAULT_REQUEST_RETRY });
187
193
  }
188
194
 
189
195
  function getSuiteTestList({
@@ -204,11 +210,11 @@ function getSuiteTestList({
204
210
  testConfigIds,
205
211
  intersections,
206
212
  },
207
- }), { reties: DEFAULT_REQUEST_RETRY });
213
+ }), { retries: DEFAULT_REQUEST_RETRY });
208
214
  }
209
215
 
210
216
  function getUsageForCurrentBillingPeriod(projectId) {
211
- return pRetry(() => getWithAuth(`/plan/project/${projectId}/usage-current-billing-period`), { reties: DEFAULT_REQUEST_RETRY })
217
+ return pRetry(() => getWithAuth(`/plan/project/${projectId}/usage-current-billing-period`), { retries: DEFAULT_REQUEST_RETRY })
212
218
  .catch((error) => {
213
219
  logger.error('failed getting usage for current billing period', { projectId, error });
214
220
  return undefined;
@@ -216,11 +222,11 @@ function getUsageForCurrentBillingPeriod(projectId) {
216
222
  }
217
223
 
218
224
  function isTestResultCompleted(resultId, projectId, testRetryKey) {
219
- return pRetry(() => getWithAuth(`/result/${resultId}/isComplete`, { projectId, testRetryKey }), { reties: DEFAULT_REQUEST_RETRY });
225
+ return pRetry(() => getWithAuth(`/result/${resultId}/isComplete`, { projectId, testRetryKey }), { retries: DEFAULT_REQUEST_RETRY });
220
226
  }
221
227
 
222
228
  function getTestResults(testId, resultId, projectId, branch) {
223
- return pRetry(() => getWithAuth(`/test/v2/${testId}/result/${resultId}`, { projectId, branch }), { reties: DEFAULT_REQUEST_RETRY });
229
+ return pRetry(() => getWithAuth(`/test/v2/${testId}/result/${resultId}`, { projectId, branch }), { retries: DEFAULT_REQUEST_RETRY });
224
230
  }
225
231
 
226
232
  function keepAliveGrid(projectId, slots) {
@@ -250,11 +256,11 @@ function getHybridGridProvider(body) {
250
256
  function getGridByName(companyId, projectId, gridName, browser, executionId) {
251
257
  return pRetry(() => getWithAuth('/grid/name', {
252
258
  companyId, projectId, name: gridName, browser, executionId, reqId: utils.guid(),
253
- }), { reties: DEFAULT_REQUEST_RETRY });
259
+ }), { retries: DEFAULT_REQUEST_RETRY });
254
260
  }
255
261
 
256
262
  function getGridById(companyId, projectId, gridId, browser, executionId) {
257
- return pRetry(() => getWithAuth(`/grid/${gridId}`, { companyId, projectId, browser, executionId, reqId: utils.guid() }), { reties: DEFAULT_REQUEST_RETRY });
263
+ return pRetry(() => getWithAuth(`/grid/${gridId}`, { companyId, projectId, browser, executionId, reqId: utils.guid() }), { retries: DEFAULT_REQUEST_RETRY });
258
264
  }
259
265
 
260
266
 
@@ -269,7 +275,7 @@ async function initializeUserWithAuth({ projectId, token, branchName, lightweigh
269
275
  lightweightMode,
270
276
  localGrid,
271
277
  },
272
- }), { reties: DEFAULT_REQUEST_RETRY });
278
+ }), { retries: DEFAULT_REQUEST_RETRY });
273
279
  } catch (e) {
274
280
  logger.error('error initializing info from server', e);
275
281
  if (e && e.message && e.message.includes('Bad Request')) {
@@ -292,7 +298,7 @@ async function getEditorUrl() {
292
298
  }
293
299
  try {
294
300
  return await pRetry(() => getWithAuth('/system-info/editor-url'), {
295
- reties: DEFAULT_REQUEST_RETRY,
301
+ retries: DEFAULT_REQUEST_RETRY,
296
302
  onFailedAttempt: error => {
297
303
  if (error.attemptNumber >= DEFAULT_REQUEST_RETRY) {
298
304
  throw error;
@@ -306,16 +312,16 @@ async function getEditorUrl() {
306
312
  }
307
313
 
308
314
  function getAllGrids(companyId) {
309
- return pRetry(() => getWithAuth('/grid', { companyId }), { reties: DEFAULT_REQUEST_RETRY });
315
+ return pRetry(() => getWithAuth('/grid', { companyId }), { retries: DEFAULT_REQUEST_RETRY });
310
316
  }
311
317
 
312
- const fetchLambdatestConfig = async () => pRetry(() => getWithAuth('/grid/lt/config'), { reties: DEFAULT_REQUEST_RETRY });
318
+ const fetchLambdatestConfig = async () => pRetry(() => getWithAuth('/grid/lt/config'), { retries: DEFAULT_REQUEST_RETRY });
313
319
 
314
- const getLabFeaturesByProjectId = async (projectId) => pRetry(() => getWithAuth(`/labFeature/v2/project/${projectId}`), { reties: DEFAULT_REQUEST_RETRY });
320
+ const getLabFeaturesByProjectId = async (projectId) => pRetry(() => getWithAuth(`/labFeature/v2/project/${projectId}`), { retries: DEFAULT_REQUEST_RETRY });
315
321
 
316
322
 
317
323
  function getRealData(projectId, channel, query) {
318
- return pRetry(() => getWithAuth(`/real-data/${channel}?${query}&projectId=${projectId}`), { reties: DEFAULT_REQUEST_RETRY });
324
+ return pRetry(() => getWithAuth(`/real-data/${channel}?${query}&projectId=${projectId}`), { retries: DEFAULT_REQUEST_RETRY });
319
325
  }
320
326
 
321
327
  function updateTestResult(projectId, resultId, testId, testResult, remoteRunId) {
@@ -328,7 +334,7 @@ function updateTestResult(projectId, resultId, testId, testResult, remoteRunId)
328
334
  testResult,
329
335
  remoteRunId,
330
336
  },
331
- }), { reties: DEFAULT_REQUEST_RETRY });
337
+ }), { retries: DEFAULT_REQUEST_RETRY });
332
338
  }
333
339
 
334
340
  function clearTestResult(projectId, resultId, testId, testResult) {
@@ -340,7 +346,7 @@ function clearTestResult(projectId, resultId, testId, testResult) {
340
346
  testId,
341
347
  testResult,
342
348
  },
343
- }), { reties: DEFAULT_REQUEST_RETRY });
349
+ }), { retries: DEFAULT_REQUEST_RETRY });
344
350
  }
345
351
 
346
352
  function saveRemoteStep(projectId, resultId, stepId, remoteStep) {
@@ -352,7 +358,7 @@ function saveRemoteStep(projectId, resultId, stepId, remoteStep) {
352
358
  stepId,
353
359
  remoteStep,
354
360
  },
355
- }), { reties: DEFAULT_REQUEST_RETRY });
361
+ }), { retries: DEFAULT_REQUEST_RETRY });
356
362
  }
357
363
 
358
364
  function relativize(uri) {
@@ -393,7 +399,7 @@ function uploadArtifact(projectId, testId, testResultId, content, subType, mimeT
393
399
 
394
400
  return pRetry(() => postAuthFormData(`/storage${storagePath}`, {}, files, {
395
401
  'X-Asset-Encoding': 'gzip',
396
- }), { reties: DEFAULT_REQUEST_RETRY }).then(() => storagePath);
402
+ }), { retries: DEFAULT_REQUEST_RETRY }).then(() => storagePath);
397
403
  }
398
404
 
399
405
  const uploadRunDataArtifact = _.memoize(async (projectId, testId, testResultId, runData) => {
@@ -443,7 +449,7 @@ function addTestRetry({
443
449
  runId,
444
450
  testResult,
445
451
  },
446
- }), { reties: DEFAULT_REQUEST_RETRY });
452
+ }), { retries: DEFAULT_REQUEST_RETRY });
447
453
  }
448
454
 
449
455
  /**
@@ -518,6 +524,7 @@ module.exports = {
518
524
  initializeUserWithAuth: Promise.method(initializeUserWithAuth),
519
525
  addTestRetry,
520
526
  getHybridGridProvider,
527
+ loadSfdcCredential,
521
528
  loadTest,
522
529
  isTestResultCompleted,
523
530
  getApplitoolsIntegrationData,
@@ -66,7 +66,8 @@ describe('testimTunnel', () => {
66
66
 
67
67
  it('should handle connect errors', async () => {
68
68
  ltConnectStub.rejects('error');
69
- await expect(testimTunnel.connect({ tunnel: true, gridData: { type: 'testimLambdaTest', tunnel: 'lambdatest' } })).to.be.rejectedWith('Failed to start tunnel. Please contact support@testim.io');
69
+ const connectPromise = testimTunnel.connect({ tunnel: true, gridData: { type: 'testimLambdaTest', tunnel: 'lambdatest' } });
70
+ await expect(connectPromise).to.be.rejectedWith('Failed to start tunnel. Please contact support@testim.io');
70
71
  });
71
72
  });
72
73