@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,13 +0,0 @@
1
- /* eslint-disable no-extend-native */
2
-
3
- Array.prototype.at = Array.prototype.at || function (index) {
4
- const relativeIndex = Number.isInteger(index) ? index : 0;
5
-
6
- const indexToRead = relativeIndex >= 0 ? relativeIndex : this.length + relativeIndex;
7
-
8
- if (indexToRead < 0 || indexToRead >= this.length) {
9
- return undefined;
10
- }
11
-
12
- return this[indexToRead];
13
- };
@@ -1,13 +0,0 @@
1
- require('./Array.prototype.at');
2
- const xhr2 = require('../commons/xhr2');
3
- const { performance } = require('perf_hooks');
4
-
5
- global.xhr2 = xhr2;
6
- global.XMLHttpRequest = xhr2;
7
-
8
- // TODO [engine:node@>=16.6.0]: can be removed once we support 16+
9
- global.performance = performance;
10
-
11
- if (typeof Blob === 'undefined') {
12
- global.Blob = require('buffer').Blob;
13
- }
package/processHandler.js DELETED
@@ -1,79 +0,0 @@
1
- /* eslint-disable no-console */
2
-
3
- 'use strict';
4
-
5
- const { getLogger } = require('./commons/logger');
6
- const { promiseTimeout, promiseMap } = require('./utils');
7
-
8
- const logger = getLogger('process-handler');
9
- /** @type {Array<() => PromiseLike<void>>} */
10
- const exitHooks = [];
11
-
12
- /**
13
- * @param {(e: any) => void} onExit
14
- * @param {NodeJS.Process=} _process
15
- */
16
- module.exports.registerProcessForCleanup = function (onExit, _process = process) {
17
- async function cleanup(err) {
18
- // give cleanup and socket reports a chance to run
19
- await promiseTimeout(promiseMap(exitHooks, hook => hook()), 10000).catch(() => null);
20
- onExit(err);
21
- }
22
- _process.on('uncaughtException', async (err) => {
23
- logger.error('Caught exception', { err });
24
- console.log('Uncaught exception');
25
- if (err.message) {
26
- console.log('Message =', err.message);
27
- }
28
- if (err.reason) {
29
- console.log('Reason =', err.reason);
30
- }
31
- await cleanup(err);
32
- });
33
-
34
- _process.on('unhandledRejection', (reason) => {
35
- // rollout manages promises incorrectly and generates unhandled rejections from within their code
36
- logger.fatal('Caught unhandled promise rejection', reason);
37
- //TODO(benji) - this is a pretty shitty way to detect this error since rollout can change their API endpoint
38
- if (reason?.message?.includes('ENOTFOUND x-api.rollout.io')) {
39
- // this is not a fatal error - we recover from this in feature-flags service
40
- return;
41
- }
42
-
43
- throw reason;
44
- });
45
-
46
- _process.on('rejectionHandled', () => {
47
- logger.error('Caught rejection handled');
48
- });
49
-
50
- _process.once('SIGTERM', () => {
51
- const msg = 'Runner aborted - SIGTERM event';
52
- const err = new Error(msg);
53
- logger.error(msg);
54
- cleanup(err);
55
- throw err;
56
- });
57
-
58
- _process.once('SIGINT', () => {
59
- const msg = 'Runner aborted - SIGINT event';
60
- const err = new Error(msg);
61
- logger.error(msg);
62
- cleanup(err);
63
- throw err;
64
- });
65
-
66
- // One time self-call is expected :(
67
- _process.once('exit', (e) => {
68
- onExit(e);
69
- });
70
- };
71
-
72
- /** @param {() => PromiseLike<void>} hook */
73
- module.exports.registerExitHook = function (hook) {
74
- exitHooks.push(hook);
75
- };
76
-
77
- module.exports.reset = function () {
78
- exitHooks.splice(0, exitHooks.length);
79
- };
@@ -1,55 +0,0 @@
1
- const EventEmitter = require('events');
2
- const processHandler = require('./processHandler');
3
- const { delay } = require('./utils');
4
- const { expect, sinon } = require('../test/utils/testUtils');
5
-
6
-
7
- class Process extends EventEmitter {
8
- constructor() {
9
- super();
10
- this.stdout = new EventEmitter();
11
- this.stderr = new EventEmitter();
12
- }
13
- }
14
-
15
- describe('testimTunnel', () => {
16
- let process;
17
- let onExitMock;
18
-
19
- beforeEach(() => {
20
- process = new Process();
21
- onExitMock = sinon.spy();
22
- processHandler.registerProcessForCleanup(onExitMock, process);
23
- });
24
-
25
- afterEach(async () => {
26
- await delay(10);
27
- expect(onExitMock).to.have.been.calledOnce;
28
- processHandler.reset();
29
- });
30
-
31
-
32
- it('should register a SIGTERM handler', (done) => {
33
- processHandler.registerExitHook(done);
34
- expect(() => process.emit('SIGTERM')).to.throw('Runner aborted - SIGTERM event');
35
- });
36
- it('should register a SIGINT handler', (done) => {
37
- processHandler.registerExitHook(done);
38
- expect(() => process.emit('SIGINT')).to.throw('Runner aborted - SIGINT event');
39
- });
40
- it('should register a unhandledRejection handler', () => {
41
- expect(() => process.emit('unhandledRejection', new Error('reason'))).to.throw('reason');
42
- onExitMock();
43
- });
44
- it('should register a uncaughtException handler', (done) => {
45
- processHandler.registerExitHook(done);
46
- expect(() => process.emit('uncaughtException', new Error())).not.to.throw();
47
- });
48
- it('should do nothing on rejectionHandled', () => {
49
- expect(() => process.emit('rejectionHandled')).not.to.throw();
50
- onExitMock();
51
- });
52
- it('should register a exit handler', () => {
53
- expect(() => process.emit('exit')).not.to.throw();
54
- });
55
- });
@@ -1,17 +0,0 @@
1
- const utils = require('../utils');
2
- const { launchChrome } = require('../commons/chrome-launcher');
3
-
4
- module.exports.ChromeReporter = class ChromeReporter {
5
- constructor(options, branchToUse) {
6
- this.options = options;
7
- this.branchToUse = branchToUse;
8
- }
9
-
10
- onTestStarted(test, workerId, isRerun, isCodeMode) {
11
- if(isCodeMode) {
12
- return
13
- }
14
- const testUrl = utils.getTestUrl(this.options.editorUrl, this.options.project, test.testId, test.resultId, this.branchToUse);
15
- return launchChrome(testUrl);
16
- }
17
- };
@@ -1,190 +0,0 @@
1
- /* eslint-disable no-console */
2
- const chalk = require('chalk');
3
- const _ = require('lodash');
4
-
5
- const utils = require('../utils');
6
- const constants = require('../commons/constants');
7
- const featureAvailabilityService = require('../commons/featureAvailabilityService');
8
- const { getAbortedTests, getFailedTests, getPassedTests, getFailureEvaluatingCount, getSkippedCount } = require('./reporterUtils');
9
-
10
- const colorize = { success: chalk.green, warn: chalk.yellow, error: chalk.red };
11
- const { CLI_MODE } = constants;
12
- const DEVICE = 'device';
13
-
14
- class ConsoleReporter {
15
- constructor(options, branchToUse) {
16
- this.options = options;
17
- this.config = {
18
- showWorkerNames: options.parallel > 1, // we show worker names when there is more than one worker
19
- };
20
- this.branchToUse = branchToUse;
21
- }
22
-
23
- toWorkerIdPrefix(workerId) {
24
- return this.config.showWorkerNames ? `W:${workerId}` : '';
25
- }
26
-
27
- printWorkerDivider() {
28
- console.log('-'.repeat(process.stdout.columns || 83));
29
- }
30
-
31
- onTestStarted(test, workerId, isRerun, isCodeMode) {
32
- const type = isCodeMode ? 'File' : 'Test';
33
- const testIdLabel = test.isTestsContainer ? '' : `(${test.testId})`;
34
- const testUrlLabel = test.isTestsContainer ? '' : `url: ${chalk.underline(utils.getTestUrl(this.options.editorUrl, this.options.project, test.testId, test.resultId, this.branchToUse))}`;
35
- console.log(this.toWorkerIdPrefix(workerId), `${type} "${test.name}" started ${testIdLabel} ${testUrlLabel}`.trim());
36
- }
37
-
38
- onTestFinished(test, workerId, isRerun, isCodeMode) {
39
- if (isCodeMode) {
40
- // ignore print of file run done
41
- return;
42
- }
43
- const testStatus = test.success ? constants.runnerTestStatus.PASSED : constants.runnerTestStatus.FAILED;
44
- const testIdLabel = test.isTestsContainer ? ' ' : `(${test.testId})`;
45
- const color = colorize[test.success ? 'success' : 'error'];
46
-
47
- console.log(color(this.toWorkerIdPrefix(workerId), `Test "${test.name}" finished status: ${testStatus} ${testIdLabel} duration: ${utils.getDuration(test.duration)}`));
48
- }
49
-
50
- printAllFailedTests(failedTests) {
51
- if (failedTests.length > 0) {
52
- const failedTestStrings = failedTests.map(failedTest => {
53
- const testUrl = utils.getTestUrl(this.options.editorUrl, this.options.project, failedTest.testId, failedTest.resultId, this.branchToUse);
54
- if (failedTest.isTestsContainer) {
55
- return failedTest.name; // no working url
56
- }
57
- return `${failedTest.name} : ${testUrl}`;
58
- });
59
- console.log(colorize.error('Failed runs are:'));
60
- console.log(colorize.error(failedTestStrings.join('\n\r')));
61
- }
62
- }
63
-
64
- onTestPlanFinished(testResults, testPlanName, duration, executionId, isAnonymous, isCodeMode) {
65
- const failedTests = getFailedTests(testResults, isCodeMode);
66
- const passedTests = getPassedTests(testResults, isCodeMode);
67
- const abortedTests = getAbortedTests(testResults, isCodeMode);
68
-
69
- const passed = passedTests.length;
70
- const aborted = abortedTests.length;
71
- let failed = failedTests.length;
72
- let failedEvaluatingString = '';
73
- let skippedString = '';
74
- if (featureAvailabilityService.isTestStatusEnabled) {
75
- const failureEvaluatingCount = getFailureEvaluatingCount(testResults);
76
- failedEvaluatingString = ` FAILED-EVALUATING: ${failureEvaluatingCount}`;
77
- failed -= failureEvaluatingCount;
78
-
79
- const skippedCount = getSkippedCount(testResults, this.options);
80
- skippedString = ` SKIPPED: ${skippedCount}`;
81
- }
82
-
83
- const planName = this.buildTestPlanName(isAnonymous, testPlanName, isCodeMode);
84
-
85
- let message;
86
- const color = colorize[failed ? 'error' : 'success'];
87
-
88
- if (isCodeMode || planName.trim() === '' || planName.trim() === 'Anonymous') {
89
- message = `Tests completed. PASSED: ${passed} FAILED: ${failed}${failedEvaluatingString} ABORTED: ${aborted}${skippedString} Duration: ${utils.getDuration(duration)} (Execution ID: ${executionId})`;
90
- } else {
91
- message = `Test plan${planName} completed PASSED: ${passed} FAILED: ${failed}${failedEvaluatingString} ABORTED: ${aborted}${skippedString} Duration: ${utils.getDuration(duration)} (${executionId})`;
92
- }
93
-
94
- this.printWorkerDivider();
95
- console.log(color(message));
96
- this.printWorkerDivider();
97
-
98
- this.printAllFailedTests(failedTests);
99
- }
100
-
101
- buildTestPlanName(isAnonymous, testPlanName, isCodeMode) {
102
- if (isCodeMode) {
103
- return '';
104
- }
105
- const suitesString = _.isEmpty(this.options.suites) ? '' : `Suite: ${this.options.suites}`;
106
- const labelsString = _.isEmpty(this.options.label) ? '' : `Label: ${this.options.label}`;
107
- const namesString = _.isEmpty(this.options.name) ? '' : `Name: ${this.options.name}`;
108
- const testIdString = _.isEmpty(this.options.testId) ? '' : `Test Id: ${this.options.testId}`;
109
- return isAnonymous ? ` anonymous (${namesString}${namesString && labelsString ? ', ' : ''}${labelsString}${suitesString && labelsString ? ', ' : ''}${suitesString}${testIdString && suitesString ? ', ' : ''}${testIdString})` : ` '${testPlanName}'`;
110
- }
111
-
112
- onTestPlanStarted(beforeTests, tests, afterTests, testPlanName, executionId, isAnonymous, configName, isCodeMode) {
113
- const writeTestList = (testList) => {
114
- testList.forEach((test, index) => {
115
- const ds = test.testData && test.testData.index ? `- ${test.testData.index} / ${test.testData.total} Data set` : '';
116
- const testIdLabel = isCodeMode ? '' : `(${test.testId})`;
117
- console.log('\t', index + 1, ':', `${test.name}${utils.isQuarantineAndNotRemoteRun(test, this.options) ? '-quarantine' : ''}`, testIdLabel, ds);
118
- });
119
- };
120
- const configString = configName ? `config '${configName}'` : 'default configs';
121
-
122
- if (isCodeMode) {
123
- console.log(`Run test plan, Project: ${this.options.project} (Execution ID: ${executionId}):`);
124
- } else {
125
- const sfdcCredentialLog = this.options.sfdcCredential ? ` SfdcCredential: ${this.options.sfdcCredential}` : '';
126
- console.log(`Run${this.buildTestPlanName(isAnonymous, testPlanName)} test plan with ${configString}, Project: ${this.options.project}, Branch: ${this.branchToUse}${sfdcCredentialLog} (${executionId})`);
127
- }
128
- this.printWorkerDivider();
129
-
130
- if (beforeTests.length > 0) {
131
- console.log('Before all:');
132
- writeTestList(beforeTests);
133
- }
134
-
135
- const listName = isCodeMode ? 'File list:' : 'Test list:';
136
- console.log(listName);
137
- writeTestList(tests);
138
-
139
- if (afterTests.length > 0) {
140
- console.log('After all:');
141
- writeTestList(afterTests);
142
- }
143
- this.printWorkerDivider();
144
- }
145
-
146
- onGetSlot(workerId, browser) {
147
- const gridNameOrId = this.options.grid || this.options.gridId;
148
- const instanceType = this.options.mode === CLI_MODE.APPIUM ? DEVICE : browser;
149
- if (gridNameOrId) {
150
- console.log(this.toWorkerIdPrefix(workerId), `Get ${chalk.underline(instanceType)} slot from ${chalk.underline(gridNameOrId)}`);
151
- }
152
- }
153
-
154
- onGetSession(workerId, testName, mode) {
155
- const instanceType = mode === CLI_MODE.APPIUM ? DEVICE : 'browser';
156
- console.log(this.toWorkerIdPrefix(workerId), `Get ${instanceType} to run ${chalk.underline(testName)}`);
157
- }
158
-
159
- onWaitToTestStart(workerId) {
160
- console.log(this.toWorkerIdPrefix(workerId), 'Wait for test start');
161
- }
162
-
163
- onWaitToTestComplete(workerId, isCodeMode, debuggerAddress) {
164
- const type = isCodeMode ? 'file' : 'test';
165
- console.log(this.toWorkerIdPrefix(workerId), `Wait for ${type} complete`);
166
- if (debuggerAddress && isCodeMode) {
167
- // TODO(Benji) decide with Amitai what we want to do with this
168
- console.log(this.toWorkerIdPrefix(workerId), `Chrome Debugger available at ${debuggerAddress}`);
169
- }
170
- }
171
-
172
- onGetBrowserFailure(workerId, projectId, attempt) {
173
- if (attempt !== 2) {
174
- return; // we want to try 2 times before showing the message once
175
- }
176
- // heuristic, show the message on the same attempt
177
- const gridNameOrId = this.options.grid || this.options.gridId;
178
- if (gridNameOrId) { // if the user passes a grid or a gridId - show those
179
- console.log(colorize.warn(this.toWorkerIdPrefix(workerId), `It is taking us some time to get a browser from the grid ${gridNameOrId}`));
180
- } else if (this.options.usingLocalChromeDriver) {
181
- console.log(colorize.warn(this.toWorkerIdPrefix(workerId), 'We are having issues starting ChromeDriver for you locally'));
182
- } else if (this.options.host) {
183
- console.log(colorize.warn(this.toWorkerIdPrefix(workerId), `We are having issues reaching your Selenium grid at ${this.options.host}:${this.options.port || 4444}`));
184
- } else {
185
- // in other cases - print nothing
186
- }
187
- }
188
- }
189
-
190
- module.exports = ConsoleReporter;
@@ -1,82 +0,0 @@
1
- 'use strict';
2
-
3
- const constants = require('../commons/constants');
4
- const logger = require('../commons/logger').getLogger('debug-reporter');
5
-
6
- const MASK_OPTIONS = {
7
- token: undefined,
8
- userParamsData: undefined,
9
- projectData: undefined,
10
- allGrids: undefined,
11
- gridData: undefined,
12
- awsAccessKeyId: undefined,
13
- awsSecretAccessKey: undefined,
14
- runParams: undefined,
15
- perfecto: undefined,
16
- testobjectSauce: undefined,
17
- };
18
-
19
- class DebugReporter {
20
- constructor(options) {
21
- this.options = options;
22
- }
23
-
24
- onTestStarted(test, workerId) {
25
- logger.info('Test Started', { testId: test.testId, testName: test.name, resultId: test.resultId, workerId });
26
- }
27
-
28
- onTestFinished(test, workerId) {
29
- const gridData = this.options.gridData || {};
30
- const provider = gridData.provider;
31
- const host = gridData.host;
32
- const gridId = gridData.gridId;
33
- const gridType = gridData.type;
34
- const failedGetBrowserAttempts = gridData.failedGetBrowserAttempts;
35
- logger.info('Test Finished', {
36
- testId: test.testId,
37
- testName: test.name,
38
- resultId: test.resultId,
39
- success: test.success,
40
- duration: test.duration,
41
- browser: this.options.browser,
42
- companyId: this.options.company.companyId,
43
- grid: { provider, host, failedGetBrowserAttempts, id: gridId, type: gridType },
44
- workerId,
45
- });
46
- }
47
-
48
- onTestPlanStarted(beforeTests, tests, afterTests, testPlanName, executionId, isAnonymous, configName) {
49
- const args = stripTokenFromConsoleArguments(process.argv);
50
-
51
- logger.info('Test Plan Started', { executionId, testPlanName, isAnonymous, configName, options: Object.assign({}, this.options, MASK_OPTIONS), args });
52
- }
53
-
54
- onTestPlanFinished(testResults, testPlanName, duration, executionId, isAnonymous) {
55
- const passed = Object.keys(testResults).filter(resultId => testResults[resultId].status === constants.runnerTestStatus.PASSED).length;
56
- const failed = Object.keys(testResults).length - passed;
57
-
58
- logger.info('Test Plan Finished', { isAnonymous, passed, failed, testPlanName, options: Object.assign({}, this.options, MASK_OPTIONS), duration, executionId });
59
- }
60
- }
61
-
62
- function stripTokenFromConsoleArguments(args) {
63
- let indexOfTokenFlag = args.indexOf('--token');
64
- if (indexOfTokenFlag === -1) {
65
- indexOfTokenFlag = args.indexOf('--t');
66
- }
67
-
68
- if (indexOfTokenFlag !== -1) {
69
- try {
70
- const newArgs = args.slice();
71
- newArgs.splice(indexOfTokenFlag, 2);
72
-
73
- return newArgs;
74
- } catch (e) {
75
- /* empty */
76
- }
77
- }
78
-
79
- return args;
80
- }
81
-
82
- module.exports = DebugReporter;
@@ -1,55 +0,0 @@
1
- /* eslint-disable no-console */
2
- class JsonReporter {
3
- constructor(options) {
4
- this.options = options;
5
- }
6
-
7
- onTestStarted(test, workerId) {
8
- const event = {
9
- name: 'testStarted',
10
- data: {
11
- test,
12
- workerId,
13
- },
14
- };
15
-
16
- console.log(JSON.stringify(event));
17
- }
18
-
19
- onTestFinished(test, workerId) {
20
- const event = {
21
- name: 'testFinished',
22
- data: {
23
- test,
24
- workerId,
25
- },
26
- };
27
-
28
- console.log(JSON.stringify(event));
29
- }
30
-
31
- onTestPlanStarted(beforeTests, tests, afterTests, testPlanName, executionId) {
32
- const event = {
33
- name: 'suiteStarted',
34
- data: {
35
- projectId: this.options.project,
36
- executionId,
37
- },
38
- };
39
-
40
- console.log(JSON.stringify(event));
41
- }
42
-
43
- onTestPlanFinished(testResults) {
44
- const event = {
45
- name: 'suiteFinished',
46
- data: {
47
- testResults,
48
- },
49
- };
50
-
51
- console.log(JSON.stringify(event));
52
- }
53
- }
54
-
55
- module.exports = JsonReporter;