@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,19 +0,0 @@
1
- 'use strict';
2
-
3
- const { ReportBase } = require('istanbul-lib-report');
4
-
5
- class SummaryToObjectReport extends ReportBase {
6
- constructor(opts) {
7
- super();
8
-
9
- opts = opts || {};
10
- this.appendToObject = opts.appendToObject || {};
11
- }
12
-
13
- onStart(node) {
14
- const summary = node.getCoverageSummary();
15
- this.appendToObject = Object.assign(this.appendToObject, summary.toJSON());
16
- }
17
- }
18
-
19
- module.exports = SummaryToObjectReport;
@@ -1,252 +0,0 @@
1
- 'use strict';
2
-
3
- const servicesApi = require('../commons/testimServicesApi');
4
- const fs = require('fs');
5
- const fsPromises = require('fs/promises');
6
- const path = require('path');
7
- const mkdirp = require('mkdirp');
8
- const lazyRequire = require('../commons/lazyRequire');
9
- const libReport = require('istanbul-lib-report');
10
- const reports = require('istanbul-reports');
11
- const SummaryToObjectReport = require('./SummaryToObjectReport');
12
- const ora = require('ora');
13
- const moment = require('moment');
14
- const TestExclude = require('test-exclude');
15
- const { ArgError } = require('../errors');
16
- const { promiseMap } = require('../utils');
17
-
18
- const logger = require('../commons/logger').getLogger('test-run-status');
19
-
20
- const convertToURL = (path) => {
21
- try {
22
- return new URL(path);
23
- } catch (err) {
24
- try {
25
- return new URL(`file://${path}`);
26
- } catch (e) {
27
- return {};
28
- }
29
- }
30
- };
31
-
32
- const pathHasQueryParam = (path) => {
33
- const urlObj = convertToURL(path);
34
- return !!urlObj.search;
35
- };
36
-
37
- const parsePath = (path) => {
38
- if (!path) {
39
- return '';
40
- }
41
- const urlObj = convertToURL(path);
42
- return urlObj.pathname.substring(1);
43
- };
44
-
45
- const excludePath = (codeCoverageInclude, path) => {
46
- const pathname = parsePath(path);
47
- const exclude = new TestExclude({
48
- relativePath: false,
49
- include: codeCoverageInclude,
50
- });
51
-
52
- return !exclude.shouldInstrument(pathname);
53
- };
54
-
55
- const removeAfterQuestionMark = (str) => str.substring(0, str.indexOf('?'));
56
-
57
- module.exports.getSourceMap = async ({ source, sourceMapDir, sourceMapType }) => {
58
- const convertSourceMap = await lazyRequire('convert-source-map');
59
- if (sourceMapType === 'file' && !sourceMapDir) {
60
- throw new ArgError('--code-coverage-source-map-path [path]');
61
- }
62
- return sourceMapDir ?
63
- convertSourceMap.fromMapFileSource(source, sourceMapDir) :
64
- convertSourceMap.fromSource(source);
65
- };
66
-
67
- module.exports.remapCoverage = async (options, storagePath, sourceMaps) => {
68
- const { codeCoverageInclude } = options;
69
- await Promise.all(Object.values(sourceMaps).map(async (sourceMap) => {
70
- if (!sourceMap) {
71
- return;
72
- }
73
- const sourceMapObject = sourceMap.toObject();
74
- await Promise.all(sourceMapObject.sources.map(async (sourcePath, index) => {
75
- if (excludePath(codeCoverageInclude, sourcePath)) {
76
- return;
77
- }
78
- const parsedPath = rewritePath(storagePath, sourcePath);
79
- await mkdirp(path.parse(parsedPath).dir);
80
- await fsPromises.writeFile(parsedPath, sourceMapObject.sourcesContent[index]);
81
- }));
82
- }));
83
- };
84
-
85
- const htmlReportLinkMapper = {
86
- getPath(node) {
87
- if (typeof node === 'string') {
88
- return node;
89
- }
90
- let filePath = node.getQualifiedName();
91
- if (node.isSummary()) {
92
- if (filePath !== '') {
93
- filePath += '/index.html';
94
- } else {
95
- filePath = 'index.html';
96
- }
97
- } else {
98
- if (pathHasQueryParam(filePath)) {
99
- filePath = removeAfterQuestionMark(filePath);
100
- }
101
- filePath += '.html';
102
- }
103
- return filePath;
104
- },
105
-
106
- relativePath(source, target) {
107
- const targetPath = this.getPath(target);
108
- const sourcePath = path.dirname(this.getPath(source));
109
- return path.posix.relative(sourcePath, targetPath);
110
- },
111
-
112
- assetPath(node, name) {
113
- return this.relativePath(this.getPath(node), name);
114
- },
115
- };
116
-
117
- const rewritePath = (storagePath, fileUrl) => {
118
- const parsedPath = path.resolve(storagePath, parsePath(fileUrl));
119
- return `${parsedPath}.js`;
120
- };
121
-
122
- module.exports.saveCoverageReports = async (options, coverageMap, reportDir, tempJsDir) => {
123
- const { codeCoverageReporter } = options;
124
- const reportSummary = {};
125
- const context = libReport.createContext({
126
- dir: reportDir,
127
- coverageMap,
128
- watermarks: libReport.getDefaultWatermarks(),
129
- sourceFinder: (filePath) => {
130
- try {
131
- const parsedPath = rewritePath(tempJsDir, filePath);
132
- return fs.readFileSync(parsedPath, 'utf8');
133
- } catch (ex) {
134
- throw new Error(`Unable to lookup source: ${filePath} (${ex.message})`);
135
- }
136
- },
137
- });
138
-
139
- (new SummaryToObjectReport({ appendToObject: reportSummary })).execute(context);
140
- if (Array.isArray(codeCoverageReporter)) {
141
- codeCoverageReporter.forEach((reporter) => {
142
- let cfg = { projectRoot: '/' };
143
- if (reporter === 'html') {
144
- cfg = { linkMapper: htmlReportLinkMapper };
145
- }
146
- reports.create(reporter, cfg).execute(context);
147
- });
148
- }
149
- return reportSummary;
150
- };
151
-
152
- module.exports.convertV8ToIstanbul = async (options, { source, sourceMap, functions }) => {
153
- const { codeCoverageInclude } = options;
154
- if (!sourceMap || sourceMap.sourcemap.sources.length === 0) {
155
- return undefined;
156
- }
157
- const v8toIstanbul = await lazyRequire('v8-to-istanbul');
158
- const converter = v8toIstanbul('FAKE_PATH', 0, {
159
- source,
160
- sourceMap,
161
- }, (path) => excludePath(codeCoverageInclude, path));
162
- await converter.load();
163
- converter.applyCoverage(functions);
164
- return converter.toIstanbul();
165
- };
166
-
167
- const collectAndMergeJsCoverageData = async (projectId, branch, runId) => {
168
- const DOWNLOAD_COVERAGE_DATA_CONCURRENCY = 20;
169
- const { mergeProcessCovs } = await lazyRequire('@bcoe/v8-coverage');
170
- let mergedCoverages = { result: [] };
171
-
172
- const covUrlMap = new Map();
173
- const realDataRes = await servicesApi.getRealData(projectId, 'testResult', `runId=${runId}`);
174
- const testResults = realDataRes.data.docs;
175
-
176
- await promiseMap(
177
- testResults.flatMap((testResult) => testResult.JSCoverageURLS || []),
178
- async (coverageURL) => {
179
- const data = await servicesApi.getS3Artifact(coverageURL, 90000);
180
- await promiseMap(data, async (cov) => {
181
- if (!covUrlMap.has(cov.url)) {
182
- let text = cov.text;
183
- if (cov.sourceUrl) {
184
- // set temp value to reduce read S3 file
185
- covUrlMap.set(cov.url, 'TEMP');
186
- text = await servicesApi.getS3ArtifactText(cov.sourceUrl);
187
- }
188
- covUrlMap.set(cov.url, {
189
- text,
190
- url: cov.url,
191
- sourceMapType: cov.sourceMapType,
192
- hash: cov.hash,
193
- });
194
- }
195
- delete cov.text;
196
- mergedCoverages = mergeProcessCovs([mergedCoverages, { result: [cov] }]);
197
- });
198
- },
199
- { concurrency: DOWNLOAD_COVERAGE_DATA_CONCURRENCY }
200
- );
201
-
202
- return { covUrlMap, mergedCoverages };
203
- };
204
-
205
- module.exports.calculateCoverage = async (options, branchToUse, numOfTests, runId) => {
206
- if (!options.collectCodeCoverage) {
207
- return undefined;
208
- }
209
- logger.info('start js coverage process');
210
- const spinner = ora(`analyzing coverage for ${numOfTests} ${numOfTests === 1 ? 'test' : 'tests'}`).start();
211
- const baseDir = path.resolve(options.codeCoverageReportPath || './coverage');
212
- const tempJsDir = path.resolve(baseDir, `.js/${moment().format('DDMMYYYYHHmmss')}`);
213
- const sourceMapDir = options.codeCoverageSourceMapPath ? path.resolve(options.codeCoverageSourceMapPath) : undefined;
214
- try {
215
- const [libCoverage, { mergedCoverages, covUrlMap }] = await Promise.all([
216
- lazyRequire('istanbul-lib-coverage'),
217
- collectAndMergeJsCoverageData(options.project, branchToUse, runId),
218
- ]);
219
-
220
- if (mergedCoverages.result.length === 0) {
221
- spinner.fail('Failed to report coverage information - js code coverage is empty');
222
- return undefined;
223
- }
224
- logger.info('start js coverage merge and remap', { numOfFiles: covUrlMap.size, numMergedCoverages: mergedCoverages.result.length });
225
- const coverageMap = libCoverage.createCoverageMap({});
226
-
227
- const sourceMaps = {};
228
- await Promise.all(mergedCoverages.result.map(async ({ url, functions }) => {
229
- const { text: source, sourceMapType } = covUrlMap.get(url);
230
-
231
- const sourceMap = await this.getSourceMap({ sourceMapType, url, source, sourceMapDir });
232
- sourceMaps[url] = sourceMap;
233
-
234
- const istanbulCoverage = await this.convertV8ToIstanbul(options, { source, sourceMap, functions });
235
- coverageMap.merge(istanbulCoverage);
236
- }));
237
- await this.remapCoverage(options, tempJsDir, sourceMaps);
238
- const coverageSummary = await this.saveCoverageReports(options, coverageMap, baseDir, tempJsDir);
239
- spinner.succeed();
240
- return coverageSummary;
241
- } catch (err) {
242
- const baseMsg = 'Failed to report coverage information';
243
- if (err instanceof ArgError) {
244
- spinner.fail(`${baseMsg}, missing arg: ${err.message}`);
245
- } else {
246
- spinner.fail(baseMsg);
247
- }
248
- logger.error(baseMsg, { err });
249
- }
250
-
251
- return undefined;
252
- };
@@ -1,142 +0,0 @@
1
- 'use strict';
2
-
3
- const fse = require('fs-extra');
4
- const path = require('path');
5
- const YAML = require('yaml');
6
- const os = require('os');
7
- const utils = require('./utils');
8
- const { launchChrome } = require('./commons/chrome-launcher');
9
-
10
- async function getProjectId() {
11
- return getCredentialProperty('projectId');
12
- }
13
-
14
- async function getToken() {
15
- return getCredentialProperty('token');
16
- }
17
-
18
- function timeout(promise, ms) {
19
- // we need this to time out even if we disabled timeouts system wide
20
- return Promise.race([promise, utils.delay(ms).then(() => { throw new utils.TimeoutError('timeout'); })]);
21
- }
22
-
23
- async function getCredentialsFromChrome() {
24
- const app = require('express')();
25
- const loginInfoFromChrome = (async function waitForChromeToSendData() {
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);
32
- }());
33
- await new Promise((resolve, reject) => {
34
- const server = app.listen(42543, (err) => {
35
- if (err) {
36
- reject(err);
37
- }
38
- resolve(server.address().port);
39
- });
40
- });
41
-
42
- const { getEditorUrl } = require('./commons/testimServicesApi');
43
-
44
- try {
45
- const url = await getEditorUrl();
46
- launchChrome(`${url}/#/new-test`);
47
- } catch (err) {
48
- // eslint-disable-next-line no-console
49
- console.log('Unable to open Testim automatically - please manually go to https://app.testim.io');
50
- }
51
-
52
- const data = await loginInfoFromChrome;
53
- return data;
54
- }
55
-
56
- async function doLogin({ overwriteExisting = true, projects = null } = {}) {
57
- const homedir = os.homedir();
58
-
59
- const testimCredentialsFile = path.join(homedir, '.testim');
60
-
61
- const isExist = await fse.pathExists(testimCredentialsFile);
62
-
63
- if (isExist && !overwriteExisting) {
64
- return;
65
- }
66
-
67
- const credentials = {};
68
-
69
- const prompts = require('prompts');
70
- const ora = require('ora');
71
-
72
- const spinner = ora('Getting credentials from Testim extension ...').start();
73
-
74
- if (!projects) {
75
- projects = await timeout(Promise.resolve(getCredentialsFromChrome()), 62000).catch(() => null);
76
- }
77
-
78
- if (projects?.token) { // V1(legacy) of the login extension API
79
- credentials.token = projects.token;
80
- credentials.projectId = projects.projectId;
81
- spinner.succeed();
82
-
83
- await writeCredentials(testimCredentialsFile, credentials);
84
- return;
85
- } if (projects?.length) { // V2(current) of the login extension API
86
- spinner.succeed();
87
-
88
- const response = projects.length === 1 ?
89
- { project: projects[0] } :
90
- await prompts({
91
- type: 'select',
92
- name: 'project',
93
- message: 'There are multiple projects associated with your user account. Please select the project you would like to connect to:',
94
- choices: projects.map(p => ({ title: p.name, value: p })),
95
- }
96
- );
97
-
98
- credentials.token = response.project.ci.token;
99
- credentials.projectId = response.project.id;
100
- await writeCredentials(testimCredentialsFile, credentials);
101
- return;
102
- }
103
-
104
- spinner.fail();
105
- // eslint-disable-next-line no-console
106
- console.log('Error getting credentials - please pass `--token` and `--project` to the CLI or try again');
107
- }
108
-
109
- async function writeCredentials(testimCredentialsFile, credentials) {
110
- await fse.writeFile(testimCredentialsFile, YAML.stringify(credentials));
111
- // eslint-disable-next-line no-console
112
- console.log(`Testim credentials saved in '${testimCredentialsFile}'`);
113
- }
114
-
115
- async function getCredentialProperty(property) {
116
- const homedir = os.homedir();
117
-
118
- const testimCredentialsFile = path.join(homedir, '.testim');
119
-
120
- const isExist = await fse.pathExists(testimCredentialsFile);
121
-
122
- let credentials = {};
123
-
124
- if (isExist) {
125
- try {
126
- credentials = YAML.parse((await fse.readFile(testimCredentialsFile)).toString());
127
- } catch (err) {
128
- // just use new credentials.
129
- }
130
- }
131
-
132
- // YAML.parse can return `null` or `undefined` if we fail with an empty/malformed file.
133
- credentials = credentials || {};
134
-
135
- return credentials[property];
136
- }
137
-
138
- module.exports = {
139
- getProjectId,
140
- getToken,
141
- doLogin,
142
- };
package/errors.js DELETED
@@ -1,161 +0,0 @@
1
- const { AbortError } = require('p-retry');
2
- /**
3
- * NoArgsError - throws when arguments not passed to cli
4
- *
5
- */
6
- function NoArgsError() {
7
- this.name = 'NoArgsError';
8
- Error.captureStackTrace(this, NoArgsError);
9
- }
10
-
11
- NoArgsError.prototype = Object.create(Error.prototype);
12
- NoArgsError.prototype.constructor = NoArgsError;
13
-
14
- /**
15
- * ArgError - throws when argument is invalid
16
- *
17
- */
18
- function ArgError(message) {
19
- this.message = message;
20
- this.name = 'ArgError';
21
- Error.captureStackTrace(this, ArgError);
22
- }
23
-
24
- ArgError.prototype = Object.create(Error.prototype);
25
- ArgError.prototype.constructor = ArgError;
26
-
27
- /**
28
- * SeleniumError - throws when selenium return error
29
- *
30
- */
31
- function SeleniumError(seleniumStack) {
32
- this.message = seleniumStack.orgStatusMessage || seleniumStack.message;
33
- this.errorType = seleniumStack.type;
34
- this.name = 'SeleniumError';
35
- Error.captureStackTrace(this, SeleniumError);
36
- }
37
-
38
- SeleniumError.prototype = Object.create(Error.prototype);
39
- SeleniumError.prototype.constructor = SeleniumError;
40
-
41
- /**
42
- * StopRunOnError
43
- *
44
- */
45
- function StopRunOnError(message) {
46
- this.message = message;
47
- this.name = 'StopRunOnError';
48
- Error.captureStackTrace(this, StopRunOnError);
49
- }
50
-
51
- StopRunOnError.prototype = Object.create(Error.prototype);
52
- StopRunOnError.prototype.constructor = StopRunOnError;
53
-
54
- class GetBrowserError extends Error {
55
- constructor(message, type) {
56
- super(message);
57
- this.type = type;
58
- }
59
- }
60
-
61
- class PageNotAvailableError extends AbortError {}
62
-
63
- class TimeoutError extends Error {}
64
-
65
- class QuotaDepletedError extends Error {}
66
-
67
- class GridError extends Error {
68
- constructor(message) {
69
- super(message);
70
- this.name = 'GridError';
71
- }
72
-
73
- toString() {
74
- return this.message;
75
- }
76
- }
77
-
78
- class GridConcurrencyError extends GridError {
79
- constructor(message) {
80
- super(message);
81
- this.name = 'GridConcurrencyError';
82
- }
83
- }
84
-
85
- /**
86
- * NpmPackageError
87
- *
88
- */
89
- function NpmPackageError(message) {
90
- this.message = message;
91
- this.name = 'NpmPackageError';
92
- Error.captureStackTrace(this, NpmPackageError);
93
- }
94
-
95
- NpmPackageError.prototype = Object.create(Error.prototype);
96
- NpmPackageError.prototype.constructor = NpmPackageError;
97
-
98
- /**
99
- * SeleniumCrashError
100
- *
101
- */
102
- function SeleniumCrashError() {
103
- this.message = 'selenium driver crashed';
104
- this.name = 'SeleniumCrashError';
105
- Error.captureStackTrace(this, SeleniumCrashError);
106
- }
107
- SeleniumCrashError.prototype = Object.create(Error.prototype);
108
- SeleniumCrashError.prototype.constructor = SeleniumCrashError;
109
-
110
- /**
111
- * IeError
112
- *
113
- */
114
- function IeError(msg = '') {
115
- this.message = msg;
116
- this.name = 'IeError';
117
- Error.captureStackTrace(this, IeError);
118
- }
119
- IeError.prototype = Object.create(Error.prototype);
120
- IeError.prototype.constructor = IeError;
121
-
122
- class ClientError extends Error {}
123
-
124
- class PlaygroundCodeError extends Error {}
125
-
126
- class NpmPermissionsError extends Error {
127
- constructor(path) {
128
- super(`Testim had missing write access to ${path}`);
129
- this.path = path;
130
- }
131
- }
132
-
133
- class NotImplementedError extends Error {
134
- constructor(descendant = false) {
135
- let message = 'not implemented';
136
- if (descendant) {
137
- message = 'should be implemented on descendant';
138
- }
139
- super(message);
140
- }
141
- }
142
-
143
- module.exports = {
144
- NoArgsError,
145
- SeleniumError,
146
- ArgError,
147
- StopRunOnError,
148
- GetBrowserError,
149
- PageNotAvailableError,
150
- GridError,
151
- GridConcurrencyError,
152
- QuotaDepletedError,
153
- NpmPackageError,
154
- NpmPermissionsError,
155
- SeleniumCrashError,
156
- IeError,
157
- ClientError,
158
- PlaygroundCodeError,
159
- NotImplementedError,
160
- TimeoutError,
161
- };
package/executionQueue.js DELETED
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- const TestRun = require('./testRunHandler');
4
-
5
- class ExecutionQueue {
6
- /**
7
- * @param {string} executionId
8
- * @param {string} executionName
9
- * @param {any[]} testList
10
- * @param {import('./runOptions').RunnerOptions} options
11
- * @param {string} branchToUse
12
- * @param {import('./testRunStatus')} testRunStatus
13
- */
14
- constructor(executionId, executionName, testList, options, branchToUse, testStatus) {
15
- this._waitingTests = testList.map(testInfo => new TestRun(executionId, executionName, testInfo, options, branchToUse, testStatus));
16
- }
17
-
18
- stop() {
19
- this._waitingTests = [];
20
- }
21
-
22
- getNext() {
23
- const nextTestRunHandler = this._waitingTests.shift();
24
- if (nextTestRunHandler) {
25
- return nextTestRunHandler;
26
- }
27
- return undefined;
28
- }
29
-
30
- hasMoreTests() {
31
- return Boolean(this._waitingTests.length);
32
- }
33
- }
34
-
35
-
36
-
37
- module.exports = ExecutionQueue;
package/fixLocalBuild.js DELETED
@@ -1,24 +0,0 @@
1
- /* eslint-disable no-console */
2
-
3
- 'use strict';
4
-
5
- // fixes the local build if running the runner locally
6
- const path = require('path');
7
- const { execSync } = require('child_process');
8
- const { existsSync } = require('fs');
9
-
10
- const location = path.resolve(__filename);
11
- const isDevBuild = !location.includes('node_modules') && path.dirname(location).endsWith('src');
12
-
13
- if (!isDevBuild) {
14
- return;
15
- }
16
-
17
- const isDepBuilt = existsSync(path.resolve(location, '..', '..', '..', 'webdriverio', 'build', 'index.js'));
18
-
19
- if (!isDepBuilt) {
20
- console.log("Hi developer, we're initializing the runner dev env for the first time for you ❤️");
21
- execSync('yarn workspace @testim/webdriverio build', {
22
- cwd: path.resolve(location, '..', '..'),
23
- });
24
- }