@testim/testim-cli 3.253.0 → 3.255.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/OverrideTestDataBuilder.js +1 -1
  2. package/agent/routers/cliJsCode/index.js +4 -4
  3. package/agent/routers/cliJsCode/router.js +46 -42
  4. package/agent/routers/cliJsCode/service.js +18 -13
  5. package/agent/routers/codim/router.js +14 -17
  6. package/agent/routers/codim/router.test.js +19 -21
  7. package/agent/routers/codim/service.js +16 -16
  8. package/agent/routers/general/index.js +4 -8
  9. package/agent/routers/hybrid/registerRoutes.js +18 -18
  10. package/agent/routers/index.js +7 -7
  11. package/agent/routers/playground/router.js +11 -10
  12. package/agent/routers/playground/service.js +22 -23
  13. package/agent/routers/standalone-browser/registerRoutes.js +10 -10
  14. package/cdpTestRunner.js +4 -3
  15. package/chromiumInstaller.js +4 -5
  16. package/cli/onExit.js +2 -2
  17. package/cli.js +11 -10
  18. package/cliAgentMode.js +8 -8
  19. package/codim/codim-cli.js +20 -17
  20. package/codim/hybrid-utils.js +1 -1
  21. package/codim/measure-perf.js +9 -6
  22. package/codim/template.js/tests/examples/01-simple-text-validation.test.js +6 -6
  23. package/codim/template.js/tests/examples/02-using-locators.test.js +13 -15
  24. package/codim/template.js/tests/examples/03-using-hooks.test.js +17 -19
  25. package/codim/template.js/tests/examples/04-skip-and-only.test.js +16 -17
  26. package/codim/template.js/tests/examples/05-multiple-windows.test.js +16 -17
  27. package/codim/template.js/webpack.config.js +1 -1
  28. package/codim/template.ts/webpack.config.js +3 -3
  29. package/commons/AbortError.js +4 -4
  30. package/commons/detectDebugger.js +4 -2
  31. package/commons/featureFlags.js +8 -0
  32. package/commons/httpRequest.js +5 -1
  33. package/commons/httpRequestCounters.js +21 -10
  34. package/commons/lazyRequire.js +14 -12
  35. package/commons/logger.js +4 -4
  36. package/commons/performance-logger.js +14 -8
  37. package/commons/preloadTests.js +2 -2
  38. package/commons/prepareRunner.js +4 -2
  39. package/commons/prepareRunnerAndTestimStartUtils.js +40 -42
  40. package/commons/runnerFileCache.js +1 -1
  41. package/commons/socket/baseSocketServiceSocketIO.js +32 -34
  42. package/commons/socket/realDataService.js +6 -5
  43. package/commons/socket/realDataServiceSocketIO.js +4 -4
  44. package/commons/socket/remoteStepService.js +4 -3
  45. package/commons/socket/remoteStepServiceSocketIO.js +11 -12
  46. package/commons/socket/socketService.js +50 -52
  47. package/commons/socket/testResultServiceSocketIO.js +11 -11
  48. package/commons/testimDesiredCapabilitiesBuilder.js +3 -2
  49. package/commons/testimNgrok.js +2 -2
  50. package/commons/testimNgrok.test.js +1 -1
  51. package/commons/testimServicesApi.js +27 -20
  52. package/commons/testimTunnel.test.js +2 -1
  53. package/commons/xhr2.js +97 -100
  54. package/coverage/SummaryToObjectReport.js +0 -1
  55. package/coverage/jsCoverage.js +12 -10
  56. package/errors.js +5 -0
  57. package/fixLocalBuild.js +2 -0
  58. package/inputFileUtils.js +11 -9
  59. package/npm-shrinkwrap.json +2286 -1284
  60. package/package.json +9 -8
  61. package/player/appiumTestPlayer.js +1 -1
  62. package/player/chromeLauncherTestPlayer.js +0 -1
  63. package/player/services/tabService.js +15 -1
  64. package/player/services/tabServiceMock.js +166 -0
  65. package/player/stepActions/locateStepAction.js +2 -0
  66. package/player/stepActions/navigationStepAction.js +11 -10
  67. package/player/stepActions/sleepStepAction.js +4 -5
  68. package/player/stepActions/textStepAction.js +4 -11
  69. package/player/utils/imageCaptureUtils.js +81 -120
  70. package/player/utils/windowUtils.js +4 -3
  71. package/player/webdriver.js +26 -23
  72. package/processHandler.js +3 -3
  73. package/processHandler.test.js +1 -1
  74. package/reports/consoleReporter.js +3 -2
  75. package/reports/junitReporter.js +7 -9
  76. package/reports/reporter.js +34 -39
  77. package/runOptions.d.ts +260 -0
  78. package/runOptions.js +59 -44
  79. package/runner.js +14 -0
  80. package/runners/ParallelWorkerManager.js +9 -10
  81. package/runners/TestPlanRunner.js +142 -78
  82. package/runners/buildCodeTests.js +38 -37
  83. package/runners/runnerUtils.js +3 -3
  84. package/services/gridService.js +36 -40
  85. package/services/lambdatestService.js +3 -5
  86. package/stepPlayers/cliJsStepPlayback.js +22 -17
  87. package/testRunHandler.js +8 -0
  88. package/testRunStatus.js +9 -6
  89. package/utils/argsUtils.js +86 -0
  90. package/utils/argsUtils.test.js +32 -0
  91. package/utils/fsUtils.js +154 -0
  92. package/{utils.js → utils/index.js} +19 -262
  93. package/utils/promiseUtils.js +89 -0
  94. package/utils/stringUtils.js +98 -0
  95. package/utils/stringUtils.test.js +22 -0
  96. package/utils/timeUtils.js +25 -0
  97. package/utils/utils.test.js +27 -0
  98. package/workers/BaseWorker.js +16 -14
  99. package/workers/WorkerAppium.js +1 -1
  100. package/workers/WorkerExtension.js +6 -7
  101. package/workers/WorkerExtensionSingleBrowser.js +4 -4
  102. package/workers/WorkerSelenium.js +5 -2
  103. package/utils.test.js +0 -68
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testim/testim-cli",
3
- "version": "3.253.0",
3
+ "version": "3.255.0",
4
4
  "description": "Command line interface for running Testing on your CI",
5
5
  "author": "Oren Rubin",
6
6
  "contributors": [{
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "lazyDependencies": {
34
34
  "ngrok": "3.4.0",
35
- "webpack": "4.43.0",
35
+ "webpack": "5.74.0",
36
36
  "playwright": "0.12.1",
37
37
  "puppeteer": "2.1.1",
38
38
  "selenium-webdriver": "3.6.0",
@@ -71,23 +71,24 @@
71
71
  "https-proxy-agent": "5.0.0",
72
72
  "istanbul-lib-report": "3.0.0",
73
73
  "istanbul-reports": "3.0.2",
74
- "jimp": "0.16.1",
74
+ "jimp": "0.16.2",
75
75
  "jsdom": "19.0.0",
76
76
  "jsonwebtoken": "8.5.1",
77
77
  "lodash": "4.17.21",
78
78
  "memory-fs": "0.5.0",
79
79
  "memorystream": "0.3.1",
80
80
  "mkdirp": "1.0.4",
81
- "moment": "2.25.3",
81
+ "moment": "2.29.4",
82
82
  "ms": "2.1.2",
83
- "npm": "8.3.0",
83
+ "npm": "8.19.2",
84
84
  "object-hash": "3.0.0",
85
85
  "ora": "5.4.1",
86
+ "p-limit": "4.0.0",
86
87
  "p-retry": "4.6.2",
87
88
  "pako": "1.0.11",
88
89
  "portfinder": "1.0.28",
89
90
  "promise-queue": "2.2.5",
90
- "prompts": "2.3.2",
91
+ "prompts": "2.4.2",
91
92
  "proxy-agent": "5.0.0",
92
93
  "rox-node": "4.9.18",
93
94
  "semver": "7.3.2",
@@ -111,8 +112,8 @@
111
112
  "testim": "cli.js"
112
113
  },
113
114
  "scripts": {
114
- "test": "IS_UNIT_TEST=1 ../../node_modules/mocha/bin/_mocha --timeout 2000 --reporter spec --exit --recursive \"./src/**/*.test.js\" --exclude ./src/codim/template.js/tests/examples/**/*.test.js",
115
- "test:watch": "IS_UNIT_TEST=1 ../../node_modules/mocha/bin/_mocha --timeout 2000 --exit --recursive \"./src/**/*.test.js\" --exclude ./src/codim/template.js/tests/examples/**/*.test.js --watch",
115
+ "test": "yarn test:pattern './src/**/*.test.js'",
116
+ "test:pattern": "IS_UNIT_TEST=1 ../../node_modules/mocha/bin/_mocha --timeout 2000 --exit --recursive --exclude ./src/codim/template.js/tests/examples/**/*.test.js --watch-files 'src'",
116
117
  "test:cov": "nyc --reporter=lcov --reporter=text yarn test",
117
118
  "upload-bundle-s3": "ts-node-transpile-only scripts/upload.js",
118
119
  "prepare-version": "rm -rf ./deploy && mkdir -p deploy && gulp prepare-version-on-prem",
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const webdriverio = require('webdriverio');
4
- const TabService = require('./services/tabService');
4
+ const TabService = require('./services/tabServiceMock');
5
5
  const PortSelector = require('./services/portSelector');
6
6
  const windowCreationListener = require('./services/windowCreationListener');
7
7
  const frameLocatorFactory = require('./services/mobileFrameLocatorMock');
@@ -3,7 +3,6 @@
3
3
  const launcher = require('chrome-launcher');
4
4
  const desiredCapabilitiesBuilder = require('../commons/testimDesiredCapabilitiesBuilder');
5
5
  const utils = require('../utils');
6
- const httpRequest = require('../commons/httpRequest');
7
6
  const { registerExitHook } = require('../processHandler');
8
7
  const CDPTestRunner = require('../cdpTestRunner');
9
8
 
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  'use strict';
2
4
 
3
5
  const sessionPlayer = require('../../commons/getSessionPlayerRequire');
@@ -36,8 +38,20 @@ const logger = require('../../commons/logger').getLogger('tab-service');
36
38
  * from: any;
37
39
  * isMain: any;
38
40
  * openerStepId: any;
41
+ * openerOriginalStepId?: any;
42
+ * isClosed?: boolean;
43
+ * currentUrl?: any;
44
+ * lastUpdatedUrl?: any;
39
45
  * }} TabInfo
40
46
  */
47
+ /**
48
+ * @typedef {{
49
+ * tabCount: number;
50
+ * tabInfos: Record<string, TabInfo>;
51
+ * lastActiveTabInfo?: any;
52
+ * currentTab?: any;
53
+ * }} SessionTab
54
+ */
41
55
 
42
56
  class TabService {
43
57
  /** @param {import('../webdriver')} driver */
@@ -45,7 +59,7 @@ class TabService {
45
59
  this.driver = driver;
46
60
  /** @type {Record<string, TabUtil>} */
47
61
  this._utils = {};
48
- /** @type {Record<string, { tabCount: number; tabInfos: Record<string, TabInfo> }>} */
62
+ /** @type {Record<string, SessionTab>} */
49
63
  this.sessionTabs = {};
50
64
  /** @type {Record<string, string>} */
51
65
  this.pendingTabs = {};
@@ -0,0 +1,166 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @typedef {{
5
+ * attachDebugger(): Promise<any>,
6
+ * detachDebugger(): Promise<any>,
7
+ * onDebuggerDetached(): {},
8
+ * tabId: string,
9
+ * domUtils: { getDOM(): Promise<any> },
10
+ * windowUtils: WindowUtils,
11
+ * imageCaptureUtils: ImageCaptureUtils
12
+ * }} TabUtil
13
+ * */
14
+ /**
15
+ * @typedef {{
16
+ * infoId: any;
17
+ * url: any;
18
+ * title: any;
19
+ * favIconUrl: any;
20
+ * order: any;
21
+ * from: any;
22
+ * isMain: any;
23
+ * openerStepId: any;
24
+ * }} TabInfo
25
+ */
26
+
27
+ class TabService {
28
+ /** @param {import('../webdriver')} driver */
29
+ constructor(driver) {
30
+ this.driver = driver;
31
+ /** @type {Record<string, TabUtil>} */
32
+ this._utils = {};
33
+ /** @type {Record<string, { tabCount: number; tabInfos: Record<string, TabInfo> }>} */
34
+ this.sessionTabs = {};
35
+ /** @type {Record<string, string>} */
36
+ this.pendingTabs = {};
37
+ /** @type {Record<string, Set<any>>} */
38
+ this.addedTabs = {};
39
+ }
40
+
41
+ on() {}
42
+
43
+ tabCount(sessionId) {
44
+ }
45
+
46
+ getAllOpenTabIds(sessionId) {
47
+ }
48
+
49
+ /**
50
+ * Get last tab info for pixel validation
51
+ *
52
+ * @returns last tab info
53
+ */
54
+ getActiveTabInfo(sessionId) {
55
+ }
56
+
57
+ getAllTabIds(sessionId) {
58
+ }
59
+
60
+ isSessionTab(sessionId, tabId) {
61
+ }
62
+
63
+ createSesion(sessionId) {
64
+ }
65
+
66
+ setAddFrameHandlerCallBack(addFrameHandlerCb) {
67
+ }
68
+
69
+ getAllTabInfoStrings(sessionId) {
70
+ }
71
+
72
+ getAllTabInfos(sessionId) {
73
+ }
74
+
75
+ addNewTab(sessionId, tabId, openerStepId, options = {}) {
76
+ }
77
+
78
+ addOpenerStepId(sessionId, tabId, openerStepId) {
79
+ }
80
+ addOpenerStep(sessionId, tabId, openerStep) {
81
+ }
82
+
83
+ fixMissingMainTab(sessionId) {
84
+ }
85
+
86
+ buildTabInfo(sessionId, tabId, order, openerStepId, options = {}) {
87
+ }
88
+
89
+ addTab(sessionId, id, order, openerStepId, options = {}) {
90
+ }
91
+
92
+ getTabUtilsByTabIdAndSessionId(sessionId, tabId) {
93
+ }
94
+
95
+ getTabUtilsByTabId(tabId) {
96
+ }
97
+
98
+ getTabInfo(sessionId, id) {
99
+ }
100
+
101
+ getTabUtils(sessionId, tabInfo) {
102
+ }
103
+
104
+ exactUrlMatch(first, second, allUrls) {
105
+ }
106
+
107
+ singleExactMatchForParts(first, second, allUrls, combinePartsFunction) {
108
+ }
109
+
110
+ isSameTab(sessionId, first, second) {
111
+ }
112
+
113
+ getMainTabInfo(sessionId) {
114
+ }
115
+
116
+ getMainTabUtils(sessionId) {
117
+ }
118
+
119
+ removeTabInfo(sessionId, tabId) {
120
+ }
121
+
122
+ getMainTabId(sessionId) {
123
+ }
124
+
125
+ isMainTabExists(sessionId) {
126
+ }
127
+
128
+ clearAllTabs(sessionId) {
129
+ }
130
+
131
+ clearNonMainTabs(sessionId) {
132
+ }
133
+
134
+ switchTab(tabId, sessionId, { forceSwitch } = { forceSwitch: false }) {
135
+ }
136
+
137
+ getTabDetails(tabId, sessionId, options = {}) {
138
+ }
139
+
140
+ getUnregisteredTabId(sessionId) {
141
+ }
142
+
143
+ waitForTabToOpen(sessionId) {
144
+ }
145
+
146
+ tryToAddTab(sessionId, openerStepId) {
147
+
148
+ }
149
+
150
+ addNewPopup(id, openerStepId) {
151
+ }
152
+
153
+ waitToPendingTabs(id, openerStepId) {
154
+ }
155
+
156
+ isMainTabIncognito() {
157
+ }
158
+
159
+ isInvalidStepVersion(step) {
160
+ }
161
+
162
+ getTabIdByTabInfo(sessionId, step) {
163
+ }
164
+ }
165
+
166
+ module.exports = TabService;
@@ -33,6 +33,7 @@ function createUtils(driver) {
33
33
  return Promise.resolve([frameHandler.frameOffset || {}]);
34
34
  }
35
35
 
36
+ /** @type {typeof import('clickim/src/background/stepActions/locateStepAction').LocateStepAction['htmlStringToDom']} */
36
37
  static htmlStringToDom(htmlString, url, nonBodyElements, bodyTagName, setDomTimeout = true) {
37
38
  const virtualConsole = new VirtualConsole();
38
39
  const jsdom = new JSDOM(htmlString, {
@@ -74,6 +75,7 @@ function createUtils(driver) {
74
75
  return true;
75
76
  }
76
77
 
78
+ /** @type {typeof import('clickim/src/background/stepActions/locateStepAction').LocateStepAction['isVisible']} */
77
79
  static isVisible(target, targetElement, rect, locateStep, frameHandler, allOffsets, dom) {
78
80
  const skipVisibilityCheck =
79
81
  featureFlags.flags.disableEdgeVisibilityChecks.isEnabled() && driver.isEdge();
@@ -1,15 +1,14 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  const StepAction = require('./stepAction');
4
- const url = require('url');
4
+ const requiredUrl = require('url');
5
5
  const Promise = require('bluebird');
6
6
 
7
7
  class NavigationStepAction extends StepAction {
8
-
9
8
  updateBaseUrl(location) {
10
- let orgUrl = url.parse(location);
11
- const baseLocation = url.parse(this.context.recordedBaseUrl);
12
- const newBaseLocation = url.parse(this.context.baseUrl);
9
+ const orgUrl = requiredUrl.parse(location);
10
+ const baseLocation = requiredUrl.parse(this.context.recordedBaseUrl);
11
+ const newBaseLocation = requiredUrl.parse(this.context.baseUrl);
13
12
  if (orgUrl.host === baseLocation.host && baseLocation.host !== newBaseLocation.host) {
14
13
  orgUrl.host = newBaseLocation.host;
15
14
  }
@@ -18,12 +17,14 @@ class NavigationStepAction extends StepAction {
18
17
 
19
18
  performAction() {
20
19
  const url = this.context.data.testimNavigationStepDestination || this.context.data.url;
21
-
20
+ // Opens a new tab and switches to new tab
21
+ if (this.step.openInNewTab) {
22
+ return this.driver.client.newWindow(url).then(() => {});
23
+ }
22
24
  return this.updateBaseUrl(url)
23
- .then(url => this.driver.url(url))
24
- .then(() => Promise.resolve());
25
+ .then(updatedUrl => this.driver.url(updatedUrl))
26
+ .then(() => {});
25
27
  }
26
-
27
28
  }
28
29
 
29
30
  module.exports = NavigationStepAction;
@@ -1,12 +1,11 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  const StepAction = require('./stepAction');
4
- const Promise = require("bluebird");
4
+ const { delay } = require('../../utils');
5
5
 
6
6
  class SleepStepAction extends StepAction {
7
-
8
- performAction() {
9
- return Promise.delay(this.step.durationMS).then(() => Promise.resolve());
7
+ async performAction() {
8
+ await delay(this.step.durationMS);
10
9
  }
11
10
  }
12
11
 
@@ -6,12 +6,10 @@ const Promise = require('bluebird');
6
6
  const { codeSnippets } = require('../../commons/getSessionPlayerRequire');
7
7
  const dispatchFocus = require('./scripts/focusElement');
8
8
  const sessionPlayer = require('../../commons/getSessionPlayerRequire');
9
- const { extractElementId } = require('../../utils');
10
- const util = require('util');
9
+ const { extractElementId, delay } = require('../../utils');
11
10
 
12
11
  const constants = sessionPlayer.commonConstants.stepResult;
13
- const setTextDraftJs = codeSnippets && codeSnippets.setTextDraftJs;
14
- const delay = util.promisify(setTimeout);
12
+ const setTextDraftJs = codeSnippets?.setTextDraftJs;
15
13
  class TextStepAction extends StepAction {
16
14
  setValueNative() {
17
15
  const context = this.context;
@@ -61,12 +59,7 @@ class TextStepAction extends StepAction {
61
59
  const eventParam = this.driver.isEdge() ? JSON.stringify(eventMessage) : eventMessage;
62
60
 
63
61
  return this.driver.executeCodeAsync(setTextCode, timeout, eventParam)
64
- .then(result => {
65
- if (result.value && result.value.success) {
66
- return Promise.resolve({ success: true });
67
- }
68
- return Promise.resolve({ success: false });
69
- });
62
+ .then(result => ({ success: Boolean(result.value?.success) }));
70
63
  }
71
64
 
72
65
  async setTextDelayed() {
@@ -86,7 +79,7 @@ class TextStepAction extends StepAction {
86
79
  const context = this.context;
87
80
  const target = this.getTarget();
88
81
 
89
- if (target && target.seleniumElement) {
82
+ if (target?.seleniumElement) {
90
83
  if (!this.step.delayBetweenChars) {
91
84
  keys.push(Array.from(context.stepText));
92
85
  return this.driver.elementIdValue(extractElementId(target.seleniumElement), keys);