@testim/testim-cli 3.289.0 → 3.290.1-beta

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 (217) hide show
  1. package/cli.js +22390 -122
  2. package/cli.js.map +1 -0
  3. package/npm-shrinkwrap.json +1169 -12846
  4. package/package.json +16 -10
  5. package/OverrideTestDataBuilder.js +0 -117
  6. package/agent/routers/cliJsCode/index.js +0 -13
  7. package/agent/routers/cliJsCode/router.js +0 -63
  8. package/agent/routers/cliJsCode/service.js +0 -705
  9. package/agent/routers/codim/router.js +0 -69
  10. package/agent/routers/codim/router.test.js +0 -60
  11. package/agent/routers/codim/service.js +0 -193
  12. package/agent/routers/general/index.js +0 -36
  13. package/agent/routers/hybrid/registerRoutes.js +0 -81
  14. package/agent/routers/index.js +0 -56
  15. package/agent/routers/playground/router.js +0 -77
  16. package/agent/routers/playground/service.js +0 -96
  17. package/agent/routers/standalone-browser/registerRoutes.js +0 -47
  18. package/agent/server.js +0 -150
  19. package/cdpTestRunner.js +0 -86
  20. package/chromiumInstaller.js +0 -91
  21. package/cli/isCiRun.js +0 -10
  22. package/cli/onExit.js +0 -65
  23. package/cli/writeStackTrace.js +0 -27
  24. package/cliAgentMode.js +0 -384
  25. package/codim/codim-cli.js +0 -91
  26. package/codim/codim-npm-package/index.ts +0 -427
  27. package/codim/codim-npm-package/package-lock.json +0 -14
  28. package/codim/codim-npm-package/package.json +0 -14
  29. package/codim/hybrid-utils.js +0 -28
  30. package/codim/measure-perf.js +0 -41
  31. package/codim/template.js/.idea/workspace.xml +0 -57
  32. package/codim/template.js/.vscode/launch.json +0 -53
  33. package/codim/template.ts/.idea/workspace.xml +0 -57
  34. package/codim/template.ts/.vscode/launch.json +0 -55
  35. package/commons/AbortError.js +0 -12
  36. package/commons/SeleniumPerfStats.js +0 -58
  37. package/commons/chrome-launcher.js +0 -15
  38. package/commons/chromedriverWrapper.js +0 -70
  39. package/commons/config.js +0 -39
  40. package/commons/constants.js +0 -67
  41. package/commons/detectDebugger.js +0 -19
  42. package/commons/featureAvailabilityService.js +0 -26
  43. package/commons/featureFlags.js +0 -132
  44. package/commons/getSessionPlayerRequire.js +0 -28
  45. package/commons/httpRequest.js +0 -261
  46. package/commons/httpRequestCounters.js +0 -98
  47. package/commons/httpRequestCounters.test.js +0 -38
  48. package/commons/initializeUserWithAuth.js +0 -55
  49. package/commons/lazyRequire.js +0 -105
  50. package/commons/logUtils.js +0 -15
  51. package/commons/logUtils.test.js +0 -21
  52. package/commons/logger.js +0 -178
  53. package/commons/mockNetworkRuleFileSchema.json +0 -140
  54. package/commons/npmWrapper.js +0 -174
  55. package/commons/npmWrapper.test.js +0 -374
  56. package/commons/performance-logger.js +0 -71
  57. package/commons/preloadTests.js +0 -29
  58. package/commons/prepareRunner.js +0 -85
  59. package/commons/prepareRunner.test.js +0 -144
  60. package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
  61. package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
  62. package/commons/requireWithFallback.js +0 -25
  63. package/commons/runnerFileCache.js +0 -204
  64. package/commons/socket/baseSocketServiceSocketIO.js +0 -197
  65. package/commons/socket/realDataService.js +0 -59
  66. package/commons/socket/realDataServiceSocketIO.js +0 -33
  67. package/commons/socket/remoteStepService.js +0 -55
  68. package/commons/socket/remoteStepServiceSocketIO.js +0 -61
  69. package/commons/socket/socketService.js +0 -175
  70. package/commons/socket/testResultService.js +0 -62
  71. package/commons/socket/testResultServiceSocketIO.js +0 -64
  72. package/commons/testimAnalytics.js +0 -40
  73. package/commons/testimCloudflare.js +0 -83
  74. package/commons/testimCloudflare.test.js +0 -185
  75. package/commons/testimCustomToken.js +0 -124
  76. package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
  77. package/commons/testimNgrok.js +0 -90
  78. package/commons/testimNgrok.test.js +0 -140
  79. package/commons/testimServicesApi.js +0 -631
  80. package/commons/testimTunnel.js +0 -73
  81. package/commons/testimTunnel.test.js +0 -172
  82. package/commons/xhr2.js +0 -897
  83. package/coverage/SummaryToObjectReport.js +0 -19
  84. package/coverage/jsCoverage.js +0 -252
  85. package/credentialsManager.js +0 -142
  86. package/errors.js +0 -161
  87. package/executionQueue.js +0 -37
  88. package/fixLocalBuild.js +0 -24
  89. package/inputFileUtils.js +0 -103
  90. package/lib/coralogix-winston.transport.js +0 -99
  91. package/player/SeleniumProtocolError.js +0 -100
  92. package/player/WebDriverHttpRequest.js +0 -177
  93. package/player/WebdriverioWebDriverApi.js +0 -671
  94. package/player/appiumTestPlayer.js +0 -90
  95. package/player/chromeLauncherTestPlayer.js +0 -67
  96. package/player/constants.js +0 -332
  97. package/player/extensionTestPlayer.js +0 -32
  98. package/player/findElementStrategy.js +0 -154
  99. package/player/scripts/isElementDisplayed.js +0 -252
  100. package/player/seleniumTestPlayer.js +0 -140
  101. package/player/services/frameLocator.js +0 -170
  102. package/player/services/mobileFrameLocatorMock.js +0 -32
  103. package/player/services/playbackTimeoutCalculator.js +0 -175
  104. package/player/services/portSelector.js +0 -19
  105. package/player/services/tabService.js +0 -551
  106. package/player/services/tabServiceMock.js +0 -167
  107. package/player/services/windowCreationListener.js +0 -8
  108. package/player/stepActions/RefreshStepAction.js +0 -16
  109. package/player/stepActions/apiStepAction.js +0 -89
  110. package/player/stepActions/baseCliJsStepAction.js +0 -51
  111. package/player/stepActions/baseJsStepAction.js +0 -277
  112. package/player/stepActions/cliConditionStepAction.js +0 -11
  113. package/player/stepActions/cliJsStepAction.js +0 -11
  114. package/player/stepActions/dropFileStepAction.js +0 -34
  115. package/player/stepActions/evaluateExpressionStepAction.js +0 -52
  116. package/player/stepActions/extensionOnlyStepAction.js +0 -12
  117. package/player/stepActions/extractTextStepAction.js +0 -19
  118. package/player/stepActions/hoverStepAction.js +0 -55
  119. package/player/stepActions/inputFileStepAction.js +0 -199
  120. package/player/stepActions/jsCodeStepAction.js +0 -11
  121. package/player/stepActions/jsConditionStepAction.js +0 -11
  122. package/player/stepActions/locateStepAction.js +0 -159
  123. package/player/stepActions/mouseStepAction.js +0 -370
  124. package/player/stepActions/navigationStepAction.js +0 -29
  125. package/player/stepActions/nodePackageStepAction.js +0 -47
  126. package/player/stepActions/pixelValidationStepAction.js +0 -39
  127. package/player/stepActions/scripts/dispatchEvents.js +0 -282
  128. package/player/stepActions/scripts/doClick.js +0 -221
  129. package/player/stepActions/scripts/doDragPath.js +0 -225
  130. package/player/stepActions/scripts/doubleClick.js +0 -119
  131. package/player/stepActions/scripts/dropEvent.js +0 -63
  132. package/player/stepActions/scripts/focusElement.js +0 -46
  133. package/player/stepActions/scripts/html5dragAction.js +0 -56
  134. package/player/stepActions/scripts/html5dragActionV2.js +0 -312
  135. package/player/stepActions/scripts/runCode.js +0 -147
  136. package/player/stepActions/scripts/scroll.js +0 -90
  137. package/player/stepActions/scripts/selectOption.js +0 -51
  138. package/player/stepActions/scripts/setText.js +0 -415
  139. package/player/stepActions/scripts/wheel.js +0 -61
  140. package/player/stepActions/scrollStepAction.js +0 -96
  141. package/player/stepActions/selectOptionStepAction.js +0 -49
  142. package/player/stepActions/sfdcRecordedStepAction.js +0 -24
  143. package/player/stepActions/sfdcStepAction.js +0 -28
  144. package/player/stepActions/sleepStepAction.js +0 -12
  145. package/player/stepActions/specialKeyStepAction.js +0 -52
  146. package/player/stepActions/stepAction.js +0 -73
  147. package/player/stepActions/stepActionRegistrar.js +0 -111
  148. package/player/stepActions/submitStepAction.js +0 -12
  149. package/player/stepActions/tdkHybridStepAction.js +0 -18
  150. package/player/stepActions/textStepAction.js +0 -110
  151. package/player/stepActions/textValidationStepAction.js +0 -64
  152. package/player/stepActions/wheelStepAction.js +0 -41
  153. package/player/utils/cookieUtils.js +0 -39
  154. package/player/utils/eyeSdkService.js +0 -250
  155. package/player/utils/imageCaptureUtils.js +0 -267
  156. package/player/utils/screenshotUtils.js +0 -68
  157. package/player/utils/stepActionUtils.js +0 -90
  158. package/player/utils/windowUtils.js +0 -195
  159. package/player/webDriverUtils.js +0 -40
  160. package/player/webDriverUtils.test.js +0 -116
  161. package/player/webdriver.js +0 -976
  162. package/polyfills/Array.prototype.at.js +0 -13
  163. package/polyfills/index.js +0 -13
  164. package/processHandler.js +0 -79
  165. package/processHandler.test.js +0 -55
  166. package/reports/chromeReporter.js +0 -17
  167. package/reports/consoleReporter.js +0 -190
  168. package/reports/debugReporter.js +0 -82
  169. package/reports/jsonReporter.js +0 -55
  170. package/reports/junitReporter.js +0 -183
  171. package/reports/reporter.js +0 -166
  172. package/reports/reporterUtils.js +0 -54
  173. package/reports/teamCityReporter.js +0 -73
  174. package/runOptions.d.ts +0 -305
  175. package/runOptions.js +0 -1288
  176. package/runOptionsAgentFlow.js +0 -87
  177. package/runOptionsUtils.js +0 -60
  178. package/runner.js +0 -355
  179. package/runners/ParallelWorkerManager.js +0 -284
  180. package/runners/TestPlanRunner.js +0 -419
  181. package/runners/buildCodeTests.js +0 -159
  182. package/runners/runnerUtils.js +0 -81
  183. package/services/analyticsService.js +0 -96
  184. package/services/branchService.js +0 -29
  185. package/services/gridService.js +0 -357
  186. package/services/gridService.test.js +0 -357
  187. package/services/labFeaturesService.js +0 -64
  188. package/services/lambdatestService.js +0 -227
  189. package/services/lambdatestService.test.js +0 -353
  190. package/services/localRCASaver.js +0 -124
  191. package/stepPlayers/cliJsStepPlayback.js +0 -40
  192. package/stepPlayers/hybridStepPlayback.js +0 -140
  193. package/stepPlayers/nodePackageStepPlayback.js +0 -28
  194. package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
  195. package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
  196. package/stepPlayers/remoteStepPlayback.js +0 -80
  197. package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
  198. package/stepPlayers/tdkHybridStepPlayback.js +0 -112
  199. package/testRunHandler.js +0 -603
  200. package/testRunStatus.js +0 -567
  201. package/testimNpmDriver.js +0 -52
  202. package/utils/argsUtils.js +0 -91
  203. package/utils/argsUtils.test.js +0 -32
  204. package/utils/fsUtils.js +0 -174
  205. package/utils/index.js +0 -197
  206. package/utils/promiseUtils.js +0 -85
  207. package/utils/stringUtils.js +0 -98
  208. package/utils/stringUtils.test.js +0 -22
  209. package/utils/timeUtils.js +0 -25
  210. package/utils/utils.test.js +0 -27
  211. package/workers/BaseWorker.js +0 -498
  212. package/workers/BaseWorker.test.js +0 -186
  213. package/workers/WorkerAppium.js +0 -180
  214. package/workers/WorkerExtension.js +0 -192
  215. package/workers/WorkerExtensionSingleBrowser.js +0 -77
  216. package/workers/WorkerSelenium.js +0 -253
  217. package/workers/workerUtils.js +0 -20
@@ -1,87 +0,0 @@
1
- // @ts-check
2
-
3
- 'use strict';
4
-
5
- const { ArgError } = require('./errors');
6
- const _ = require('lodash');
7
- const runOptionsUtils = require('./runOptionsUtils');
8
- const analytics = require('./commons/testimAnalytics');
9
-
10
- /**
11
- *
12
- * @param {import("commander").CommanderStatic} program
13
- */
14
- function isAgentFlow(program) {
15
- if (program.start) {
16
- analytics.track(null, 'cli-start-command', { downloadBrowser: Boolean(program.downloadBrowser) });
17
- }
18
- if (program.startV2 || program.start || program.agent) {
19
- return true;
20
- }
21
-
22
- return false;
23
- }
24
-
25
- /**
26
- *
27
- * @param {Readonly<import("commander").CommanderStatic>} program
28
- */
29
- async function runAgentFlow(program) {
30
- const agentModes = ['playground-playwright', 'playground-puppeteer', 'playground-selenium'];
31
- let installPlaygroundPlaywrightDeps = false;
32
- let installPlaygroundPuppeteerDeps = false;
33
- let installPlaygroundSeleniumDeps = false;
34
-
35
- let startTestimBrowser = false;
36
-
37
- if (program.start) {
38
- startTestimBrowser = true;
39
- }
40
-
41
- if (_.isNaN(program.agentPort)) {
42
- return Promise.reject(new ArgError('Agent port is not number'));
43
- }
44
-
45
- if (typeof program.agent === 'string' && agentModes.some(mode => program.agent.includes(mode))) {
46
- const selectedModes = program.agent.split(',').map(mode => mode.trim());
47
- if (selectedModes.includes('playground-playwright')) {
48
- installPlaygroundPlaywrightDeps = true;
49
- }
50
-
51
- if (selectedModes.includes('playground-puppeteer')) {
52
- installPlaygroundPuppeteerDeps = true;
53
- }
54
-
55
- if (selectedModes.includes('playground-selenium')) {
56
- installPlaygroundSeleniumDeps = true;
57
- }
58
- }
59
-
60
- const playerUrl = runOptionsUtils.getPlayerUrl(program);
61
-
62
- console.log('Start Testim CLI on Agent mode');
63
- return {
64
- project: program.project,
65
- token: program.token,
66
- agentMode: true,
67
- agentPort: program.agentPort,
68
- agentBind: program.agentBind,
69
- openEditor: program.openEditor,
70
- installPlaygroundPlaywrightDeps,
71
- installPlaygroundPuppeteerDeps,
72
- installPlaygroundSeleniumDeps,
73
- startTestimBrowser,
74
- ext: program.ext,
75
- extensionPath: program.extensionPath,
76
- playerLocation: program.playerPath || playerUrl,
77
- canary: program.canary,
78
- playerPath: program.playerPath,
79
- playerRequirePath: program.playerRequirePath,
80
- downloadBrowser: Boolean(program.downloadBrowser),
81
- };
82
- }
83
-
84
- module.exports = {
85
- isAgentFlow,
86
- runAgentFlow,
87
- };
@@ -1,60 +0,0 @@
1
- // @ts-check
2
-
3
- 'use strict';
4
-
5
- const config = require('./commons/config');
6
-
7
- module.exports = {
8
- getExtensionsUrl,
9
- getResolvedExtensionUrl,
10
- getPlayerUrl,
11
- };
12
-
13
- /**
14
- *
15
- * @param {Readonly<import("commander").CommanderStatic>} program
16
- */
17
- function getExtensionsUrl(program, useCanonicalURL) {
18
- const zipFileSuffix = program.canary ? '-master.zip' : '.zip';
19
- let firefox;
20
- let chrome;
21
- if (!useCanonicalURL) {
22
- firefox = `${config.BLOB_URL}/extension/testim-firefox-profile${zipFileSuffix}`;
23
- chrome = `${config.BLOB_URL}/extension/testim-headless${zipFileSuffix}`;
24
- } else {
25
- firefox = `${config.CANONICAL_BLOB_URL}/extension/testim-firefox-profile${zipFileSuffix}`;
26
- chrome = `${config.CANONICAL_EDGE_URL}/extension/testim-headless${zipFileSuffix}`;
27
- }
28
- return {
29
- firefox,
30
- chrome,
31
- 'edge-chromium': chrome,
32
- };
33
- }
34
-
35
- /**
36
- *
37
- * @param {Readonly<import("commander").CommanderStatic>} program
38
- */
39
- function getResolvedExtensionUrl(program) {
40
- const { chrome, firefox } = getExtensionsUrl(program, false);
41
-
42
- if (program.browser === 'firefox') {
43
- return firefox;
44
- }
45
- if (program.browser === 'chrome') {
46
- return chrome;
47
- }
48
- return [chrome, firefox];
49
- }
50
-
51
- /**
52
- *
53
- * @param {Readonly<import("commander").CommanderStatic>} program
54
- */
55
- function getPlayerUrl(program) {
56
- const playerUrlPrefix = `${config.BLOB_URL}/extension/sessionPlayer`;
57
- const playerUrl = program.canary ? `${playerUrlPrefix}-master` : playerUrlPrefix;
58
-
59
- return playerUrl;
60
- }
package/runner.js DELETED
@@ -1,355 +0,0 @@
1
- 'use strict';
2
-
3
- /* eslint-disable no-console */
4
- const _ = require('lodash');
5
- const utils = require('./utils');
6
- const reporter = require('./reports/reporter');
7
- const npmDriver = require('./testimNpmDriver');
8
- const tunnel = require('./commons/testimTunnel');
9
- const perf = require('./commons/performance-logger');
10
- const gridService = require('./services/gridService');
11
- const analytics = require('./commons/testimAnalytics');
12
- const featureFlags = require('./commons/featureFlags');
13
- const branchService = require('./services/branchService');
14
- const servicesApi = require('./commons/testimServicesApi');
15
- const TestPlanRunner = require('./runners/TestPlanRunner');
16
- const socketService = require('./commons/socket/socketService');
17
- const testimCustomToken = require('./commons/testimCustomToken');
18
- const labFeaturesService = require('./services/labFeaturesService');
19
- const featureAvailabilityService = require('./commons/featureAvailabilityService');
20
- const { getLogger } = require('./commons/logger');
21
- const { EDITOR_URL } = require('./commons/config');
22
- const { CLI_MODE } = require('./commons/constants');
23
- const { ArgError, QuotaDepletedError } = require('./errors');
24
- const { prepareMockNetwork, initializeUserWithAuth } = require('./commons/prepareRunner');
25
-
26
- const FREE_PLAN_MINIMUM_BROWSER_TIMEOUT = 30 * 60 * 1000;
27
-
28
-
29
- const logger = getLogger('runner');
30
-
31
- /** @param {import('./runOptions').RunnerOptions} options */
32
- function validateCLIRunsAreAllowed(options) {
33
- const hasCliAccess = _.get(options, 'company.activePlan.premiumFeatures.allowCLI');
34
-
35
- if (!hasCliAccess) {
36
- const projectId = options.project;
37
- analytics.track(options.authData.uid, 'cli-not-supported', { projectId });
38
- console.warn('Testim CLI is not supported in this plan');
39
- // TODO: shouldn't this throw an error? 🤔
40
- }
41
- }
42
-
43
- /** @param {import('./runOptions').RunnerOptions} options */
44
- async function validateProjectQuotaNotDepleted(options) {
45
- const projectId = options.project;
46
-
47
- const usage = await servicesApi.getUsageForCurrentBillingPeriod(projectId);
48
- const isExecutionBlocked = usage?.isExecutionBlocked;
49
- if (!isExecutionBlocked) {
50
- return;
51
- }
52
-
53
- console.error('You have reached the limit of runs for the billing month, please upgrade your plan at https://www.testim.io/upgrade-contact-us?source=cli');
54
- analytics.track(options.authData.uid, 'execution-quota-surpassed', { projectId });
55
- throw new QuotaDepletedError();
56
- }
57
-
58
- /**
59
- * @param {import('./runOptions').RunnerOptions} options
60
- * @param {Awaited<ReturnType<initializeUserWithAuth>>['companyByProjectId']} company
61
- */
62
- function validateOptionsForCompany(options, company) {
63
- const optionsRetention = options.retentionDays;
64
- if (!optionsRetention) {
65
- return;
66
- }
67
-
68
- const companyRetention = _.get(company, 'activePlan.premiumFeatures.resultRetention');
69
- if (optionsRetention > companyRetention) {
70
- throw new ArgError(`Retention days (${optionsRetention}) cannot be greater than the company's retention days (${companyRetention}). Run aborted`);
71
- }
72
- }
73
-
74
- /** @param {import('./runOptions').RunnerOptions} options */
75
- async function validateCliAccount(options) {
76
- if (options.lightweightMode?.disableQuotaBlocking) {
77
- return;
78
- }
79
- try {
80
- await Promise.all([
81
- validateProjectQuotaNotDepleted(options),
82
- validateCLIRunsAreAllowed(options),
83
- ]);
84
- } catch (err) {
85
- if ([ArgError, QuotaDepletedError].some(errType => err instanceof errType)) {
86
- throw err;
87
- }
88
- logger.error('could not validate cli account', { err });
89
- }
90
- }
91
-
92
- /** @param {string} projectId */
93
- function analyticsIdentify(projectId) {
94
- const authData = testimCustomToken.getTokenV3UserData();
95
- return analytics.identify({
96
- userId: authData.uid,
97
- name: authData.uid,
98
- traits: {
99
- projectId,
100
- company: {
101
- id: projectId,
102
- lastCIRun: Math.floor(Date.now() / 1000), // unix timestamp
103
- },
104
- },
105
- });
106
- }
107
-
108
- /** @param {string} projectId */
109
- function initSocketServices(projectId, { disableResults = false, disableRemoteStep = false }) {
110
- if (featureFlags.flags.useNewWSCLI.isEnabled() && !disableResults && !disableRemoteStep) {
111
- return socketService.connect(projectId);
112
- }
113
- if (!disableRemoteStep) {
114
- const remoteStepService = require('./commons/socket/remoteStepService');
115
- remoteStepService.init(projectId);
116
- }
117
- if (!disableResults) {
118
- const testResultService = require('./commons/socket/testResultService');
119
- testResultService.init(projectId);
120
- }
121
- return undefined;
122
- }
123
-
124
- /**
125
- * @param {import('./runOptions').RunnerOptions} options
126
- * @param {Awaited<ReturnType<initializeUserWithAuth>>['branchName']} branchInfoFromServer
127
- */
128
- function setBranch(options, branchInfoFromServer) {
129
- const { branch, autoDetect } = options;
130
- branchService.setCurrentBranch(branchInfoFromServer, autoDetect);
131
- if (!branchInfoFromServer && !autoDetect) {
132
- throw new ArgError(`branch ${branch} does not exist, run aborted.`);
133
- }
134
- }
135
-
136
- /** @param {import('./runOptions').RunnerOptions} options */
137
- async function setSfdcCredential(options) {
138
- const { projectData: { projectId } = {} } = options;
139
- const branch = branchService.getCurrentBranch();
140
- if (_.get(options, 'company.activePlan.premiumFeatures.ttaForSalesforce')) {
141
- options.sfdcCredential = await servicesApi.loadSfdcCredential({ projectId, branch });
142
- }
143
- }
144
-
145
- /**
146
- * @param {import('./runOptions').RunnerOptions} options
147
- * @param {Awaited<ReturnType<initializeUserWithAuth>>['companyByProjectId']} company
148
- */
149
- function setCompany(options, company) {
150
- const { onprem, id, storageBaseUrl, storageType, name, activePlan = {} } = company;
151
- if (onprem) {
152
- const { mode, extensionPath, ext, playerPath } = options;
153
- if ([CLI_MODE.SELENIUM].includes(mode) && !playerPath) {
154
- throw new ArgError('in selenium on prem mode --player-path must be provided');
155
- }
156
- if (mode === 'extension' && !extensionPath && !ext) {
157
- throw new ArgError('In extension on prem mode --ext or --extension-path must be provided');
158
- }
159
- }
160
- const isPOC = Boolean(activePlan.isPoc);
161
- const isStartUp = Boolean(activePlan.isStartUp);
162
- const planType = utils.getPlanType(activePlan);
163
- if (planType === 'free') {
164
- options.newBrowserWaitTimeout = options.newBrowserWaitTimeout < FREE_PLAN_MINIMUM_BROWSER_TIMEOUT ? FREE_PLAN_MINIMUM_BROWSER_TIMEOUT : options.newBrowserWaitTimeout;
165
- }
166
- featureFlags.setCompanyId(id);
167
- featureFlags.setIsPOC(isPOC);
168
- featureFlags.setIsStartUp(isStartUp);
169
- featureFlags.setPlanType(planType);
170
- featureAvailabilityService.setPlanType(planType);
171
- options.company = {
172
- companyId: id,
173
- onprem,
174
- storageBaseUrl,
175
- storageType,
176
- name,
177
- planType,
178
- isPOC,
179
- isStartUp,
180
- activePlan,
181
- };
182
- }
183
-
184
- /**
185
- * @param {import('./runOptions').RunnerOptions} options
186
- * @param {Awaited<ReturnType<initializeUserWithAuth>>['editorConfig']} editorConfig
187
- */
188
- function setSystemInfo(options, editorConfig) {
189
- if (EDITOR_URL) {
190
- options.editorUrl = EDITOR_URL;
191
- return;
192
- }
193
- options.editorUrl = editorConfig.editorUrl;
194
- }
195
-
196
- /**
197
- * @param {import('./runOptions').RunnerOptions} options
198
- * @param {Awaited<ReturnType<initializeUserWithAuth>>['allGrids']} allGrids
199
- */
200
- function setAllGrids(options, allGrids) {
201
- options.allGrids = allGrids;
202
- }
203
-
204
- /**
205
- * @param {import('./runOptions').RunnerOptions} options
206
- * @param {Awaited<ReturnType<initializeUserWithAuth>>['authData']} authData
207
- */
208
- function setAuthData(options, authData) {
209
- options.authData = authData;
210
- }
211
-
212
- /**
213
- * @param {import('./runOptions').RunnerOptions} options
214
- * @param {Awaited<ReturnType<initializeUserWithAuth>>['projectById']} project
215
- */
216
- function setProject(options, project) {
217
- const { id, name, type, defaults } = project;
218
- featureFlags.setProjectId(id);
219
- featureFlags.setProjectType(type);
220
- options.projectData = {
221
- projectId: id,
222
- type,
223
- name,
224
- defaults,
225
- };
226
- }
227
-
228
- /** @param {import('./runOptions').RunnerOptions} options */
229
- async function setGrid(options) {
230
- options.gridData = await gridService.getGridData(options);
231
- }
232
-
233
- /** @param {import('./runOptions').RunnerOptions} options */
234
- async function setMockNetworkRules(options) {
235
- const { project } = options;
236
- const props = { projectId: project };
237
-
238
- if (options.overrideMappingFile) {
239
- analytics.trackWithCIUser('user-override-file', props);
240
- options.mockNetworkRules = await prepareMockNetwork(options.overrideMappingFile);
241
- }
242
- }
243
-
244
- /**
245
- * @param {import('./runOptions').RunnerOptions} options
246
- * @param {string=} customExtensionLocalLocation
247
- */
248
- async function runRunner(options, customExtensionLocalLocation) {
249
- perf.log('in runner.js runRunner');
250
-
251
- const { project, remoteRunId, useLocalChromeDriver, useChromeLauncher } = options;
252
-
253
- if (!remoteRunId) {
254
- options.source = (useLocalChromeDriver || useChromeLauncher) ? 'cli-local' : 'cli';
255
- }
256
-
257
- await npmDriver.checkNpmVersion();
258
- perf.log('in runner.js after checkNpmVersion');
259
-
260
- await validateCliAccount(options);
261
-
262
- perf.log('in runRunner before tunnel.connect');
263
- await tunnel.connect(options);
264
- perf.log('in runRunner after tunnel.connect');
265
-
266
- const testPlanRunner = new TestPlanRunner(customExtensionLocalLocation);
267
- const results = await testPlanRunner.run(options);
268
-
269
- perf.log('before tunnel.disconnect');
270
- await tunnel.disconnect(options);
271
- await gridService.keepAlive.end(project);
272
- perf.log('after tunnel.disconnect and gridService.keepAlive.end');
273
-
274
- return results;
275
- }
276
-
277
- /** @param {import('./runOptions').RunnerOptions} options */
278
- function showFreeGridRunWarningIfNeeded(options) {
279
- if (featureAvailabilityService.shouldShowFreeGridRunWarning(options.gridData?.type)) {
280
- const CYAN = '\x1b[36m';
281
- const UNDERSCORE = '\x1b[4m';
282
- const RESET = '\x1b[0m';
283
- const MESSAGE = 'Our Free grid offers basic service performance.\nIf you need faster results, contact us to upgrade your plan and dramatically improve your tests’ run times.';
284
- console.log(`\n${UNDERSCORE}${CYAN}${MESSAGE}${RESET}\n`);
285
- }
286
- }
287
-
288
- /**
289
- * This method initializes the Testim CLI with all the information it needs to start executing, it takes care of:
290
- *
291
- * - Reporting the user to analytics
292
- * - Authenticating the user and exchanging their token for a jwt
293
- * - Sets the grids for the company and validates the user has permission to run the CLI
294
- * @param {import('./runOptions').RunnerOptions} options - the run options passed to the CLI, namely the project and token
295
- */
296
- async function init(options) {
297
- perf.log('start runner init');
298
- const { project, lightweightMode, useChromeLauncher, mode, disableSockets } = options;
299
- const featureFlagsReady = featureFlags.fetch();
300
- const socketConnected = initSocketServices(project, {
301
- disableResults: disableSockets || Boolean(lightweightMode?.disableResults && (useChromeLauncher || mode !== 'extension')),
302
- disableRemoteStep: disableSockets || Boolean(lightweightMode?.disableRemoteStep),
303
- });
304
-
305
- featureFlagsReady.catch(() => {}); // suppress unhandled rejection
306
- Promise.resolve(socketConnected).catch(() => {}); // only sometimes a promise
307
-
308
- const { authData, editorConfig, companyByProjectId, projectById, branchName, allGrids } = await initializeUserWithAuth(options);
309
-
310
- validateOptionsForCompany(options, companyByProjectId);
311
- await Promise.all([featureFlagsReady, socketConnected]);
312
-
313
- if (options.browser && featureFlags.flags.dec2022eolBrowsers.isEnabled()) {
314
- const browser = utils.getBrowserInfo(options.browser);
315
- if (browser.eol) {
316
- throw new ArgError(`Unsupported browser: ${browser.browserName}`);
317
- }
318
- }
319
-
320
- perf.log('after featureFlagsReady and socketConnected');
321
- setSystemInfo(options, editorConfig);
322
- setCompany(options, companyByProjectId);
323
- setProject(options, projectById);
324
- setBranch(options, branchName);
325
- setAllGrids(options, allGrids);
326
- setAuthData(options, authData);
327
- await setSfdcCredential(options);
328
-
329
- if (!options.lightweightMode?.disableLabs) {
330
- await labFeaturesService.loadLabFeatures(projectById.id, companyByProjectId.activePlan);
331
- }
332
-
333
- if (options.lightweightMode && options.lightweightMode.type === 'turboMode' && (featureFlags.flags.highSpeedMode.getValue() === 'disabled' || options.company.planType === 'free')) {
334
- delete options.lightweightMode;
335
- }
336
-
337
- if (options.lightweightMode && options.lightweightMode.type === 'turboMode') {
338
- // eslint-disable-next-line max-len
339
- console.log('\nTurbo mode will ignore step delays. Test artifacts like screenshots and logs will only be saved for failed runs. For more information see our docs: https://help.testim.io/docs/turbo-mode');
340
- }
341
-
342
- gridService.keepAlive.start(project);
343
- analyticsIdentify(project);
344
- await setMockNetworkRules(options);
345
- await setGrid(options);
346
- showFreeGridRunWarningIfNeeded(options);
347
-
348
- const branchToUse = branchService.getCurrentBranch();
349
- reporter.setOptions(options, branchToUse);
350
- }
351
-
352
- module.exports = {
353
- run: runRunner,
354
- init,
355
- };