@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.
- package/cli.js +22390 -122
- package/cli.js.map +1 -0
- package/npm-shrinkwrap.json +1169 -12846
- package/package.json +16 -10
- package/OverrideTestDataBuilder.js +0 -117
- package/agent/routers/cliJsCode/index.js +0 -13
- package/agent/routers/cliJsCode/router.js +0 -63
- package/agent/routers/cliJsCode/service.js +0 -705
- package/agent/routers/codim/router.js +0 -69
- package/agent/routers/codim/router.test.js +0 -60
- package/agent/routers/codim/service.js +0 -193
- package/agent/routers/general/index.js +0 -36
- package/agent/routers/hybrid/registerRoutes.js +0 -81
- package/agent/routers/index.js +0 -56
- package/agent/routers/playground/router.js +0 -77
- package/agent/routers/playground/service.js +0 -96
- package/agent/routers/standalone-browser/registerRoutes.js +0 -47
- package/agent/server.js +0 -150
- package/cdpTestRunner.js +0 -86
- package/chromiumInstaller.js +0 -91
- package/cli/isCiRun.js +0 -10
- package/cli/onExit.js +0 -65
- package/cli/writeStackTrace.js +0 -27
- package/cliAgentMode.js +0 -384
- package/codim/codim-cli.js +0 -91
- package/codim/codim-npm-package/index.ts +0 -427
- package/codim/codim-npm-package/package-lock.json +0 -14
- package/codim/codim-npm-package/package.json +0 -14
- package/codim/hybrid-utils.js +0 -28
- package/codim/measure-perf.js +0 -41
- package/codim/template.js/.idea/workspace.xml +0 -57
- package/codim/template.js/.vscode/launch.json +0 -53
- package/codim/template.ts/.idea/workspace.xml +0 -57
- package/codim/template.ts/.vscode/launch.json +0 -55
- package/commons/AbortError.js +0 -12
- package/commons/SeleniumPerfStats.js +0 -58
- package/commons/chrome-launcher.js +0 -15
- package/commons/chromedriverWrapper.js +0 -70
- package/commons/config.js +0 -39
- package/commons/constants.js +0 -67
- package/commons/detectDebugger.js +0 -19
- package/commons/featureAvailabilityService.js +0 -26
- package/commons/featureFlags.js +0 -132
- package/commons/getSessionPlayerRequire.js +0 -28
- package/commons/httpRequest.js +0 -261
- package/commons/httpRequestCounters.js +0 -98
- package/commons/httpRequestCounters.test.js +0 -38
- package/commons/initializeUserWithAuth.js +0 -55
- package/commons/lazyRequire.js +0 -105
- package/commons/logUtils.js +0 -15
- package/commons/logUtils.test.js +0 -21
- package/commons/logger.js +0 -178
- package/commons/mockNetworkRuleFileSchema.json +0 -140
- package/commons/npmWrapper.js +0 -174
- package/commons/npmWrapper.test.js +0 -374
- package/commons/performance-logger.js +0 -71
- package/commons/preloadTests.js +0 -29
- package/commons/prepareRunner.js +0 -85
- package/commons/prepareRunner.test.js +0 -144
- package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
- package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
- package/commons/requireWithFallback.js +0 -25
- package/commons/runnerFileCache.js +0 -204
- package/commons/socket/baseSocketServiceSocketIO.js +0 -197
- package/commons/socket/realDataService.js +0 -59
- package/commons/socket/realDataServiceSocketIO.js +0 -33
- package/commons/socket/remoteStepService.js +0 -55
- package/commons/socket/remoteStepServiceSocketIO.js +0 -61
- package/commons/socket/socketService.js +0 -175
- package/commons/socket/testResultService.js +0 -62
- package/commons/socket/testResultServiceSocketIO.js +0 -64
- package/commons/testimAnalytics.js +0 -40
- package/commons/testimCloudflare.js +0 -83
- package/commons/testimCloudflare.test.js +0 -185
- package/commons/testimCustomToken.js +0 -124
- package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
- package/commons/testimNgrok.js +0 -90
- package/commons/testimNgrok.test.js +0 -140
- package/commons/testimServicesApi.js +0 -631
- package/commons/testimTunnel.js +0 -73
- package/commons/testimTunnel.test.js +0 -172
- package/commons/xhr2.js +0 -897
- package/coverage/SummaryToObjectReport.js +0 -19
- package/coverage/jsCoverage.js +0 -252
- package/credentialsManager.js +0 -142
- package/errors.js +0 -161
- package/executionQueue.js +0 -37
- package/fixLocalBuild.js +0 -24
- package/inputFileUtils.js +0 -103
- package/lib/coralogix-winston.transport.js +0 -99
- package/player/SeleniumProtocolError.js +0 -100
- package/player/WebDriverHttpRequest.js +0 -177
- package/player/WebdriverioWebDriverApi.js +0 -671
- package/player/appiumTestPlayer.js +0 -90
- package/player/chromeLauncherTestPlayer.js +0 -67
- package/player/constants.js +0 -332
- package/player/extensionTestPlayer.js +0 -32
- package/player/findElementStrategy.js +0 -154
- package/player/scripts/isElementDisplayed.js +0 -252
- package/player/seleniumTestPlayer.js +0 -140
- package/player/services/frameLocator.js +0 -170
- package/player/services/mobileFrameLocatorMock.js +0 -32
- package/player/services/playbackTimeoutCalculator.js +0 -175
- package/player/services/portSelector.js +0 -19
- package/player/services/tabService.js +0 -551
- package/player/services/tabServiceMock.js +0 -167
- package/player/services/windowCreationListener.js +0 -8
- package/player/stepActions/RefreshStepAction.js +0 -16
- package/player/stepActions/apiStepAction.js +0 -89
- package/player/stepActions/baseCliJsStepAction.js +0 -51
- package/player/stepActions/baseJsStepAction.js +0 -277
- package/player/stepActions/cliConditionStepAction.js +0 -11
- package/player/stepActions/cliJsStepAction.js +0 -11
- package/player/stepActions/dropFileStepAction.js +0 -34
- package/player/stepActions/evaluateExpressionStepAction.js +0 -52
- package/player/stepActions/extensionOnlyStepAction.js +0 -12
- package/player/stepActions/extractTextStepAction.js +0 -19
- package/player/stepActions/hoverStepAction.js +0 -55
- package/player/stepActions/inputFileStepAction.js +0 -199
- package/player/stepActions/jsCodeStepAction.js +0 -11
- package/player/stepActions/jsConditionStepAction.js +0 -11
- package/player/stepActions/locateStepAction.js +0 -159
- package/player/stepActions/mouseStepAction.js +0 -370
- package/player/stepActions/navigationStepAction.js +0 -29
- package/player/stepActions/nodePackageStepAction.js +0 -47
- package/player/stepActions/pixelValidationStepAction.js +0 -39
- package/player/stepActions/scripts/dispatchEvents.js +0 -282
- package/player/stepActions/scripts/doClick.js +0 -221
- package/player/stepActions/scripts/doDragPath.js +0 -225
- package/player/stepActions/scripts/doubleClick.js +0 -119
- package/player/stepActions/scripts/dropEvent.js +0 -63
- package/player/stepActions/scripts/focusElement.js +0 -46
- package/player/stepActions/scripts/html5dragAction.js +0 -56
- package/player/stepActions/scripts/html5dragActionV2.js +0 -312
- package/player/stepActions/scripts/runCode.js +0 -147
- package/player/stepActions/scripts/scroll.js +0 -90
- package/player/stepActions/scripts/selectOption.js +0 -51
- package/player/stepActions/scripts/setText.js +0 -415
- package/player/stepActions/scripts/wheel.js +0 -61
- package/player/stepActions/scrollStepAction.js +0 -96
- package/player/stepActions/selectOptionStepAction.js +0 -49
- package/player/stepActions/sfdcRecordedStepAction.js +0 -24
- package/player/stepActions/sfdcStepAction.js +0 -28
- package/player/stepActions/sleepStepAction.js +0 -12
- package/player/stepActions/specialKeyStepAction.js +0 -52
- package/player/stepActions/stepAction.js +0 -73
- package/player/stepActions/stepActionRegistrar.js +0 -111
- package/player/stepActions/submitStepAction.js +0 -12
- package/player/stepActions/tdkHybridStepAction.js +0 -18
- package/player/stepActions/textStepAction.js +0 -110
- package/player/stepActions/textValidationStepAction.js +0 -64
- package/player/stepActions/wheelStepAction.js +0 -41
- package/player/utils/cookieUtils.js +0 -39
- package/player/utils/eyeSdkService.js +0 -250
- package/player/utils/imageCaptureUtils.js +0 -267
- package/player/utils/screenshotUtils.js +0 -68
- package/player/utils/stepActionUtils.js +0 -90
- package/player/utils/windowUtils.js +0 -195
- package/player/webDriverUtils.js +0 -40
- package/player/webDriverUtils.test.js +0 -116
- package/player/webdriver.js +0 -976
- package/polyfills/Array.prototype.at.js +0 -13
- package/polyfills/index.js +0 -13
- package/processHandler.js +0 -79
- package/processHandler.test.js +0 -55
- package/reports/chromeReporter.js +0 -17
- package/reports/consoleReporter.js +0 -190
- package/reports/debugReporter.js +0 -82
- package/reports/jsonReporter.js +0 -55
- package/reports/junitReporter.js +0 -183
- package/reports/reporter.js +0 -166
- package/reports/reporterUtils.js +0 -54
- package/reports/teamCityReporter.js +0 -73
- package/runOptions.d.ts +0 -305
- package/runOptions.js +0 -1288
- package/runOptionsAgentFlow.js +0 -87
- package/runOptionsUtils.js +0 -60
- package/runner.js +0 -355
- package/runners/ParallelWorkerManager.js +0 -284
- package/runners/TestPlanRunner.js +0 -419
- package/runners/buildCodeTests.js +0 -159
- package/runners/runnerUtils.js +0 -81
- package/services/analyticsService.js +0 -96
- package/services/branchService.js +0 -29
- package/services/gridService.js +0 -357
- package/services/gridService.test.js +0 -357
- package/services/labFeaturesService.js +0 -64
- package/services/lambdatestService.js +0 -227
- package/services/lambdatestService.test.js +0 -353
- package/services/localRCASaver.js +0 -124
- package/stepPlayers/cliJsStepPlayback.js +0 -40
- package/stepPlayers/hybridStepPlayback.js +0 -140
- package/stepPlayers/nodePackageStepPlayback.js +0 -28
- package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
- package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
- package/stepPlayers/remoteStepPlayback.js +0 -80
- package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
- package/stepPlayers/tdkHybridStepPlayback.js +0 -112
- package/testRunHandler.js +0 -603
- package/testRunStatus.js +0 -567
- package/testimNpmDriver.js +0 -52
- package/utils/argsUtils.js +0 -91
- package/utils/argsUtils.test.js +0 -32
- package/utils/fsUtils.js +0 -174
- package/utils/index.js +0 -197
- package/utils/promiseUtils.js +0 -85
- package/utils/stringUtils.js +0 -98
- package/utils/stringUtils.test.js +0 -22
- package/utils/timeUtils.js +0 -25
- package/utils/utils.test.js +0 -27
- package/workers/BaseWorker.js +0 -498
- package/workers/BaseWorker.test.js +0 -186
- package/workers/WorkerAppium.js +0 -180
- package/workers/WorkerExtension.js +0 -192
- package/workers/WorkerExtensionSingleBrowser.js +0 -77
- package/workers/WorkerSelenium.js +0 -253
- package/workers/workerUtils.js +0 -20
package/testRunHandler.js
DELETED
|
@@ -1,603 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const _ = require('lodash');
|
|
4
|
-
const pRetry = require('p-retry');
|
|
5
|
-
const utils = require('./utils');
|
|
6
|
-
const config = require('./commons/config');
|
|
7
|
-
const perf = require('./commons/performance-logger');
|
|
8
|
-
const analytics = require('./commons/testimAnalytics');
|
|
9
|
-
const testimCustomToken = require('./commons/testimCustomToken');
|
|
10
|
-
const testimServicesApi = require('./commons/testimServicesApi');
|
|
11
|
-
const remoteStepPlayback = require('./stepPlayers/remoteStepPlayback');
|
|
12
|
-
const remoteStepService = require('./commons/socket/remoteStepService');
|
|
13
|
-
const testResultService = require('./commons/socket/testResultService');
|
|
14
|
-
const { URL } = require('url');
|
|
15
|
-
const { getLogger } = require('./commons/logger');
|
|
16
|
-
const { preloadTests } = require('./commons/preloadTests');
|
|
17
|
-
const { timeoutMessages, CLI_MODE } = require('./commons/constants');
|
|
18
|
-
const { SeleniumPerfStats } = require('./commons/SeleniumPerfStats');
|
|
19
|
-
|
|
20
|
-
const logger = getLogger('test-run-handler');
|
|
21
|
-
const RETRIES_ON_TIMEOUT = 3;
|
|
22
|
-
const MAX_LIGHTWEIGHT_MODE_RUN_DATA_SIZE = 20 * 1000; // max size, in characters, of stringified run data sent over URL params. Chosen arbitrarily, this value should be changed according to data.
|
|
23
|
-
const canSendRunDataOverUrl = (runData) => JSON.stringify(runData).length < MAX_LIGHTWEIGHT_MODE_RUN_DATA_SIZE;
|
|
24
|
-
|
|
25
|
-
class TestRun {
|
|
26
|
-
/**
|
|
27
|
-
* @param {string} executionId
|
|
28
|
-
* @param {string} executionName
|
|
29
|
-
* @param {import('./runners/TestPlanRunner').ExecutionList[number]} test
|
|
30
|
-
* @param {import('./runOptions').RunnerOptions} options
|
|
31
|
-
* @param {string} branchToUse
|
|
32
|
-
* @param {import('./testRunStatus')} testRunStatus
|
|
33
|
-
*/
|
|
34
|
-
constructor(executionId, executionName, test, options, branchToUse, testRunStatus) {
|
|
35
|
-
this._executionId = executionId;
|
|
36
|
-
this._executionName = executionName;
|
|
37
|
-
this._testStatus = test.testStatus;
|
|
38
|
-
this._testId = test.testId;
|
|
39
|
-
this._testName = test.name;
|
|
40
|
-
this._testResultId = test.resultId;
|
|
41
|
-
this._code = test.code;
|
|
42
|
-
this._baseUrl = options.baseUrl || test.baseUrl || test.testConfig.baseUrl;
|
|
43
|
-
this._nativeApp = test.nativeApp;
|
|
44
|
-
this._overrideTestConfigId = test.overrideTestConfig?.id;
|
|
45
|
-
this._options = options;
|
|
46
|
-
this._branch = branchToUse;
|
|
47
|
-
this._maxRetryCount = options.retries;
|
|
48
|
-
this._remoteRunId = options.remoteRunId;
|
|
49
|
-
this._retryCount = 1;
|
|
50
|
-
this._timeoutRetryCount = 1;
|
|
51
|
-
this._totalRetryCount = 1;
|
|
52
|
-
|
|
53
|
-
this._testRunStatus = testRunStatus;
|
|
54
|
-
const shouldUpdateConfig = !test.runConfig?.isMobileWeb && options.browser;
|
|
55
|
-
this._runConfig = shouldUpdateConfig ? utils.getRunConfigByBrowserName(options.browser, options.saucelabs, options.browserstack) : test.runConfig;
|
|
56
|
-
this.clearTestResultFinished = Promise.resolve();
|
|
57
|
-
|
|
58
|
-
this.seleniumPerfStats = new SeleniumPerfStats();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async waitForExecutionStartedFinished() {
|
|
62
|
-
return await this._testRunStatus.waitForExecutionStartedFinished() && await this.clearTestResultFinished;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get testStatus() {
|
|
66
|
-
return this._testStatus;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get runMode() {
|
|
70
|
-
return this._options.mode;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get automationMode() {
|
|
74
|
-
return this._code ? 'codeful' : 'codeless';
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get code() {
|
|
78
|
-
return this._code;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get runConfig() {
|
|
82
|
-
return this._runConfig;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
get testResultId() {
|
|
86
|
-
return this._testResultId;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
get baseUrl() {
|
|
90
|
-
return this._baseUrl;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get executionId() {
|
|
94
|
-
return this._executionId;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
get executionName() {
|
|
98
|
-
return this._executionName;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
get androidActivityWait() {
|
|
102
|
-
const appData = 'appMetadata' in this._nativeApp ? this._nativeApp.appMetadata : this._nativeApp;
|
|
103
|
-
if (appData.activity.includes(appData.id)) {
|
|
104
|
-
return `${appData.id}.*`;
|
|
105
|
-
}
|
|
106
|
-
const { activity } = appData;
|
|
107
|
-
const lastValue = activity.split('.').pop();
|
|
108
|
-
return activity.replace(lastValue, '*');
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
get nativeAppLink() {
|
|
112
|
-
let link = null;
|
|
113
|
-
if ('filePath' in this._nativeApp) {
|
|
114
|
-
link = `${config.SERVICES_HOST}/storage${this._nativeApp.filePath}?access_token=${this._options.authData.token}`;
|
|
115
|
-
}
|
|
116
|
-
return link;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async getNativeAppData() {
|
|
120
|
-
const { appId, baseUrl } = this._options;
|
|
121
|
-
if (baseUrl && !this._nativeApp && !appId) {
|
|
122
|
-
const url = baseUrl || this.baseUrl;
|
|
123
|
-
if (!url) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
const [packageName, activity] = url.split(':');
|
|
127
|
-
return {
|
|
128
|
-
packageName,
|
|
129
|
-
activity,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
if (this._nativeApp && !appId) {
|
|
133
|
-
if ('appMetadata' in this._nativeApp) {
|
|
134
|
-
return this._nativeApp.appMetadata;
|
|
135
|
-
}
|
|
136
|
-
return this._nativeApp;
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
get branch() {
|
|
142
|
-
return this._branch;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
get sfdcCredential() {
|
|
146
|
-
return this._options.sfdcCredential;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
get remoteRunId() {
|
|
150
|
-
return this._remoteRunId;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
get overrideTestConfigId() {
|
|
154
|
-
return this._overrideTestConfigId;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
markClearBrowser() {
|
|
158
|
-
this.clearBrowser = true;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async getRunRequestParams() {
|
|
162
|
-
const customTokenV3 = await testimCustomToken.getCustomTokenV3();
|
|
163
|
-
const runRequestParams = {
|
|
164
|
-
tokenV3: customTokenV3,
|
|
165
|
-
refreshToken: testimCustomToken.getRefreshToken(),
|
|
166
|
-
projectId: this._options.project,
|
|
167
|
-
executionId: this._executionId,
|
|
168
|
-
executionName: this._executionName,
|
|
169
|
-
testId: this._testId,
|
|
170
|
-
resultId: this._testResultId,
|
|
171
|
-
baseUrl: this._baseUrl,
|
|
172
|
-
branch: this._branch,
|
|
173
|
-
servicesUrl: config.EXTENSION_SERVICES_HOST,
|
|
174
|
-
remoteRunId: this.remoteRunId,
|
|
175
|
-
previousTestResultId: this.previousTestResultId,
|
|
176
|
-
testRetryCount: this.retryCount,
|
|
177
|
-
...(this.code && { isCodeMode: true, testName: this.testName }),
|
|
178
|
-
...(this._options.shouldMonitorPerformance && { shouldMonitorPerformance: true }),
|
|
179
|
-
...(this._options.company && {
|
|
180
|
-
companyId: this._options.company.companyId,
|
|
181
|
-
onprem: this._options.company.onprem,
|
|
182
|
-
storageBaseUrl: this._options.company.storageBaseUrl,
|
|
183
|
-
storageType: this._options.company.storageType,
|
|
184
|
-
planType: this._options.company.planType,
|
|
185
|
-
isPOC: this._options.company.isPOC,
|
|
186
|
-
isStartUp: this._options.company.isStartUp,
|
|
187
|
-
}),
|
|
188
|
-
...(this._options.collectCodeCoverage && { codeCoverageUrlFilter: this._options.codeCoverageUrlFilter || `${this.baseUrl}*` }),
|
|
189
|
-
...(this._options.disableMockNetwork && { disableMockNetwork: this._options.disableMockNetwork }),
|
|
190
|
-
...(this._options.lightweightMode && { lightweightMode: this._options.lightweightMode }),
|
|
191
|
-
...(this.clearBrowser && { clearBrowser: true }),
|
|
192
|
-
...(this._options.localRCASaver && { localRCASaver: this._options.localRCASaver }),
|
|
193
|
-
...(this.sfdcCredential && { sfdcCredential: this.sfdcCredential }),
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
if (this._options.disableMockNetwork) {
|
|
197
|
-
analytics.trackWithCIUser('user-disable-mock');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (this._options.lightweightMode?.general) {
|
|
201
|
-
runRequestParams.company = this._options.company;
|
|
202
|
-
const runData = this.runData;
|
|
203
|
-
runRequestParams.lightweightMode.isRunDataSentInUrl = canSendRunDataOverUrl(runData);
|
|
204
|
-
const stringifiedLength = JSON.stringify(runData).length;
|
|
205
|
-
const testId = this.testId;
|
|
206
|
-
if (runRequestParams.lightweightMode.isRunDataSentInUrl) {
|
|
207
|
-
runRequestParams.runData = runData;
|
|
208
|
-
logger.info(`Run data sent as URL param, test id: ${testId} run data length: ${stringifiedLength}`);
|
|
209
|
-
} else {
|
|
210
|
-
logger.warn(`Run data is too big to be sent as a URL param. Test id: ${testId}, run data size: ${stringifiedLength} (limit: ${MAX_LIGHTWEIGHT_MODE_RUN_DATA_SIZE} characters)`);
|
|
211
|
-
}
|
|
212
|
-
runRequestParams.isLocalRun = Boolean(this._options.useLocalChromeDriver || this._options.useChromeLauncher);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (this._options.lightweightMode?.preloadTests && this._options.useChromeLauncher) {
|
|
216
|
-
const preloadedTests = await preloadTests(this._options);
|
|
217
|
-
runRequestParams.preloadedTest = preloadedTests[runRequestParams.testId];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return runRequestParams;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
async getRunTestUrl() {
|
|
224
|
-
const runRequestParams = await this.getRunRequestParams();
|
|
225
|
-
const url = `https://run.testim.io/?params=${encodeURIComponent(JSON.stringify(runRequestParams))}`;
|
|
226
|
-
logger.info(`Test (${this.testId}) run URL length: ${url.length}`);
|
|
227
|
-
return url;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
set sessionId(sessionId) {
|
|
231
|
-
this._sessionId = sessionId;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
get sessionId() {
|
|
235
|
-
return this._sessionId;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
get testId() {
|
|
239
|
-
return this._testId;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
get testName() {
|
|
243
|
-
return this._testName;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
get runParams() {
|
|
247
|
-
return this._options.runParams[this._testResultId] || {};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
get runData() {
|
|
251
|
-
return {
|
|
252
|
-
userParamsData: this.runParams,
|
|
253
|
-
overrideTestConfigId: this._overrideTestConfigId || null,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
async clearTestResult() {
|
|
258
|
-
const runData = this.runData;
|
|
259
|
-
if (this.runMode === CLI_MODE.EXTENSION) {
|
|
260
|
-
runData.code = this.code;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (this._options.mockNetworkRules) {
|
|
264
|
-
runData.mockNetworkRules = this._options.mockNetworkRules;
|
|
265
|
-
}
|
|
266
|
-
const mustClearPreviousStepResults = (this._timeoutRetryCount > 1 || this._retryCount > 1);
|
|
267
|
-
|
|
268
|
-
if (this._options.lightweightMode?.disableResults && !mustClearPreviousStepResults && canSendRunDataOverUrl(runData)) {
|
|
269
|
-
return undefined;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const uploadRunDataArtifactAndFallbackToEmptyString = async () => {
|
|
273
|
-
try {
|
|
274
|
-
return await testimServicesApi.uploadRunDataArtifact(this._options.project, this._testId, this._testResultId, runData);
|
|
275
|
-
} catch (err) {
|
|
276
|
-
logger.error('failed to upload run data artifact (runner)', { err });
|
|
277
|
-
return '';
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
const clearTestResultFinished = async () => {
|
|
281
|
-
const runDataUrl = await uploadRunDataArtifactAndFallbackToEmptyString();
|
|
282
|
-
// make sure the execution is created by now
|
|
283
|
-
await this._testRunStatus.waitForExecutionStartedFinished();
|
|
284
|
-
// we probably can save this backend call by initializing the execution
|
|
285
|
-
return testimServicesApi.clearTestResult(this._options.project, this._testResultId, this._testId, {
|
|
286
|
-
name: this._testName,
|
|
287
|
-
resultId: this._testResultId,
|
|
288
|
-
status: 'pending',
|
|
289
|
-
retryCount: this._retryCount,
|
|
290
|
-
runDataUrl, // links the run data url to the test.
|
|
291
|
-
runData: runDataUrl ? undefined : runData, // put runData in mongo if we fail to upload to S3.
|
|
292
|
-
testRetryKey: this.retryKey,
|
|
293
|
-
});
|
|
294
|
-
};
|
|
295
|
-
this.clearTestResultFinished = clearTestResultFinished();
|
|
296
|
-
return this.clearTestResultFinished;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
hasMoreRetries() {
|
|
300
|
-
return this._retryCount < this._maxRetryCount;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
get retryKey() {
|
|
304
|
-
return `${this._retryCount}:${this._timeoutRetryCount}`;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
startNewRetry() {
|
|
308
|
-
this._retryCount++;
|
|
309
|
-
this._timeoutRetryCount = 1;
|
|
310
|
-
return this.onRetry();
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
async runTestUsingCDP(cdpTestRunner) {
|
|
314
|
-
perf.log('runTestUsingCDP');
|
|
315
|
-
const { targetInfos } = await cdpTestRunner.cdpCommand('Target.getTargets') || { targetInfos: [] };
|
|
316
|
-
const { targetId: extensionTargetId } = targetInfos.find(target => target.type === 'background_page' && target.title === 'Testim Editor') || {};
|
|
317
|
-
const { targetId: AUTTargetId } = targetInfos.find(target => target.type === 'page') || {};
|
|
318
|
-
if (!extensionTargetId) {
|
|
319
|
-
throw new Error('testim extension not found');
|
|
320
|
-
}
|
|
321
|
-
if (!AUTTargetId) {
|
|
322
|
-
throw new Error('AUT target not found');
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
try {
|
|
326
|
-
perf.log('before Target.attachToTarget');
|
|
327
|
-
const [extensionSession, runRequestParams] = await Promise.all([
|
|
328
|
-
cdpTestRunner.cdpCommand('Target.attachToTarget', { targetId: extensionTargetId, flatten: true }),
|
|
329
|
-
this.getRunRequestParams(),
|
|
330
|
-
]);
|
|
331
|
-
const { sessionId: extensionSessionId } = extensionSession || {};
|
|
332
|
-
perf.log('before Runtime.evaluate');
|
|
333
|
-
|
|
334
|
-
await pRetry(async () => {
|
|
335
|
-
const { result } = await cdpTestRunner.cdpCommand('Runtime.evaluate', { expression: 'typeof runTestimTest !== \'undefined\'', returnByValue: true }, extensionSessionId);
|
|
336
|
-
if (!result.value) {
|
|
337
|
-
throw new Error('runTestimTest not available on global scope');
|
|
338
|
-
}
|
|
339
|
-
}, { retries: 100, minTimeout: 30, factor: 1 });
|
|
340
|
-
|
|
341
|
-
perf.log('after wait for runTestimTest function');
|
|
342
|
-
const { result } = await cdpTestRunner.cdpCommand(
|
|
343
|
-
'Runtime.evaluate',
|
|
344
|
-
{ expression: `runTestimTest(${JSON.stringify(runRequestParams)})`, awaitPromise: true, returnByValue: true },
|
|
345
|
-
extensionSessionId,
|
|
346
|
-
);
|
|
347
|
-
if (result.subtype === 'error') {
|
|
348
|
-
throw new Error(result.description);
|
|
349
|
-
}
|
|
350
|
-
perf.log('after Runtime.evaluate');
|
|
351
|
-
return result.value;
|
|
352
|
-
} catch (err) {
|
|
353
|
-
logger.error('error running test using CDP', { err });
|
|
354
|
-
throw new Error('Error running test using CDP');
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
isRetryKeyMismatch(testResult) {
|
|
359
|
-
return testResult.testRetryKey && (testResult.testRetryKey !== this.retryKey);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
validateRunConfig() {
|
|
363
|
-
const { baseUrl, runConfig: { browserValue } } = this;
|
|
364
|
-
|
|
365
|
-
if (baseUrl && browserValue === 'safari') {
|
|
366
|
-
let parsedUrl;
|
|
367
|
-
try {
|
|
368
|
-
parsedUrl = new URL(baseUrl);
|
|
369
|
-
} catch (err) {
|
|
370
|
-
// ignore invalid URLs (missing http:// or https:// prefix)
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const { username, password } = parsedUrl;
|
|
374
|
-
|
|
375
|
-
if (username || password) {
|
|
376
|
-
throw new Error('Basic authentication in URL is not supported in Safari');
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/** @param {number} startTimeout */
|
|
382
|
-
onStarted(startTimeout) {
|
|
383
|
-
return new Promise(resolve => {
|
|
384
|
-
// We can't leave the test result as it may remove other listeners as well
|
|
385
|
-
// We need to implement an .off(resultId, listener) method
|
|
386
|
-
let reportedStart = false;
|
|
387
|
-
const resolveResult = testResult => {
|
|
388
|
-
if (reportedStart) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
if (this.isRetryKeyMismatch(testResult)) {
|
|
392
|
-
logger.warn(`ignoring result update for on started due to retry key mismatch, got ${testResult.testRetryKey}, current is ${this.retryKey}`, {
|
|
393
|
-
resultId: this.testResultId,
|
|
394
|
-
testId: this.testId,
|
|
395
|
-
});
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
if (['running', 'completed'].includes(testResult.status)) {
|
|
399
|
-
testResult.resultId = this.testResultId;
|
|
400
|
-
if (testResult.status === 'completed') {
|
|
401
|
-
logger.info('setting _wasCompletedOnStartedCheck to true', {
|
|
402
|
-
testResult,
|
|
403
|
-
resultId: this.testResultId,
|
|
404
|
-
testId: this.testId,
|
|
405
|
-
testRetryKey: this.retryKey,
|
|
406
|
-
});
|
|
407
|
-
this._wasCompletedOnStartedCheck = testResult;
|
|
408
|
-
}
|
|
409
|
-
reportedStart = true;
|
|
410
|
-
resolve(testResult);
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
if (this._options.disableSockets) {
|
|
414
|
-
const timeLimit = Date.now() + startTimeout;
|
|
415
|
-
const checkIfDone = async () => {
|
|
416
|
-
if (Date.now() > timeLimit) {
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
const { testId, testResultId, branch, _options: { project: projectId } } = this;
|
|
420
|
-
|
|
421
|
-
try {
|
|
422
|
-
const restResult = await testimServicesApi.getTestResults(testId, testResultId, projectId, branch);
|
|
423
|
-
resolveResult(restResult);
|
|
424
|
-
if (!reportedStart) {
|
|
425
|
-
setTimeout(checkIfDone, 3000);
|
|
426
|
-
}
|
|
427
|
-
} catch (err) {
|
|
428
|
-
logger.error('failed to check if done', { err });
|
|
429
|
-
setTimeout(checkIfDone, 3000);
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
setTimeout(checkIfDone, 3000);
|
|
433
|
-
} else {
|
|
434
|
-
testResultService.listenToTestResult(this._testResultId, this._testId, resolveResult);
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
async checkViaRestAPIIfTestStarted() {
|
|
440
|
-
const { testId, testResultId, _options: { project: projectId }, branch } = this;
|
|
441
|
-
try {
|
|
442
|
-
const testResult = testimServicesApi.getTestResults(testId, testResultId, projectId, branch);
|
|
443
|
-
const expectedStatuses = ['running', 'completed'];
|
|
444
|
-
if (expectedStatuses.includes(testResult.status)) {
|
|
445
|
-
logger.info(`get status: ${testResult.status} after not get test started status`, { testId, testResultId, branch });
|
|
446
|
-
return testResult;
|
|
447
|
-
}
|
|
448
|
-
logger.error(`test not start test status: ${testResult.status} (expected [${expectedStatuses.join(', ')}])`, { testId, testResultId, branch });
|
|
449
|
-
throw new Error(timeoutMessages.TEST_START_TIMEOUT_MSG);
|
|
450
|
-
} catch (err) {
|
|
451
|
-
logger.error('failed to get test result after test start timeout', { err, testId, testResultId, branch });
|
|
452
|
-
throw new Error(timeoutMessages.TEST_START_TIMEOUT_MSG);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
async onCompletedCleanup() {
|
|
457
|
-
if (this._options.disableSockets) {
|
|
458
|
-
return undefined;
|
|
459
|
-
}
|
|
460
|
-
return await testResultService.leaveTestResult(this._testResultId, this._testId);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
async onCompleted() {
|
|
464
|
-
let onConnected;
|
|
465
|
-
try {
|
|
466
|
-
const res = await new Promise(resolve => {
|
|
467
|
-
if (this._wasCompletedOnStartedCheck && !this.isRetryKeyMismatch(this._wasCompletedOnStartedCheck)) {
|
|
468
|
-
logger.info('test was already completed in on started check', {
|
|
469
|
-
resultId: this.testResultId,
|
|
470
|
-
testId: this.testId,
|
|
471
|
-
});
|
|
472
|
-
resolve(this._wasCompletedOnStartedCheck);
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
if (!this._options.disableSockets) {
|
|
477
|
-
testResultService.listenToTestResult(this._testResultId, this._testId, testResult => {
|
|
478
|
-
if (this.isRetryKeyMismatch(testResult)) {
|
|
479
|
-
logger.warn(`ignoring result update for on completed due to retry key mismatch, got ${testResult.testRetryKey}, current is ${this.retryKey}`, {
|
|
480
|
-
resultId: this.testResultId,
|
|
481
|
-
testId: this.testId,
|
|
482
|
-
});
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
if (testResult.status === 'completed') {
|
|
486
|
-
testResult.resultId = this._testResultId;
|
|
487
|
-
resolve(testResult);
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
const debounceDelay = this._options.disableSockets ? 0 : Math.floor(10000 + (Math.random() * 5000));
|
|
492
|
-
const maxWait = this._options.disableSockets ? 0 : Math.floor(60000 + (Math.random() * 15000));
|
|
493
|
-
onConnected = _.debounce(async () => {
|
|
494
|
-
try {
|
|
495
|
-
const testResult = await testimServicesApi.getTestResults(this._testId, this._testResultId, this._options.project, this.branch);
|
|
496
|
-
if (this.isRetryKeyMismatch(testResult)) {
|
|
497
|
-
logger.warn(`ignoring result update for on completed (in reconnect) due to retry key mismatch, got ${testResult.testRetryKey}, current is ${this.retryKey}`, {
|
|
498
|
-
resultId: this.testResultId,
|
|
499
|
-
testId: this.testId,
|
|
500
|
-
});
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
if (testResult?.status === 'completed') {
|
|
504
|
-
logger.info('Socket reconnected - Test complete', { testId: this._testId, resultId: this._testResultId, projectId: this._options.project });
|
|
505
|
-
testResult.resultId = this._testResultId;
|
|
506
|
-
resolve(testResult);
|
|
507
|
-
return true;
|
|
508
|
-
}
|
|
509
|
-
return false;
|
|
510
|
-
} catch (err) {
|
|
511
|
-
logger.warn('Error while trying to check status on socket connect', err);
|
|
512
|
-
return false;
|
|
513
|
-
}
|
|
514
|
-
}, debounceDelay, { maxWait });
|
|
515
|
-
if (!this._options.disableSockets) {
|
|
516
|
-
testResultService.on('socket-connected', onConnected);
|
|
517
|
-
} else {
|
|
518
|
-
const waitForTestEnd = () => {
|
|
519
|
-
setTimeout(async () => {
|
|
520
|
-
try {
|
|
521
|
-
const { isComplete } = await testimServicesApi.isTestResultCompleted(this._testResultId, this._options.project, this.retryKey);
|
|
522
|
-
if (isComplete) {
|
|
523
|
-
const isDone = await onConnected();
|
|
524
|
-
if (!isDone) {
|
|
525
|
-
logger.warn('onConnected returned false even though isComplete was true');
|
|
526
|
-
waitForTestEnd();
|
|
527
|
-
}
|
|
528
|
-
} else {
|
|
529
|
-
waitForTestEnd();
|
|
530
|
-
}
|
|
531
|
-
} catch (err) {
|
|
532
|
-
logger.error('failed to check is complete', { err });
|
|
533
|
-
waitForTestEnd();
|
|
534
|
-
}
|
|
535
|
-
}, 3000);
|
|
536
|
-
};
|
|
537
|
-
waitForTestEnd();
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
await this.onCompletedCleanup();
|
|
541
|
-
return res;
|
|
542
|
-
} finally {
|
|
543
|
-
if (onConnected && !this._options.disableSockets) {
|
|
544
|
-
testResultService.off('socket-connected', onConnected);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
listenToRemoteStep(browser) {
|
|
550
|
-
remoteStepService.listenToRemoteStep(this.testResultId, step => {
|
|
551
|
-
remoteStepPlayback.executeStep(this._options, browser, step, this.testResultId);
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
hasMoreTimeoutRetries() {
|
|
556
|
-
const maxRetryCount = this._options.disableTimeoutRetry ? 1 : RETRIES_ON_TIMEOUT;
|
|
557
|
-
return this._timeoutRetryCount < maxRetryCount;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
startNewTimeoutRetry() {
|
|
561
|
-
this._timeoutRetryCount++;
|
|
562
|
-
return this.onRetry();
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
get retryCount() {
|
|
566
|
-
return this._retryCount;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
get previousTestResultId() {
|
|
570
|
-
return this._previousTestResultId;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
isAllowReportTestResultRetries() {
|
|
574
|
-
return Boolean(this._options.company?.activePlan?.premiumFeatures?.allowReportTestResultRetries);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
async onRetry() {
|
|
578
|
-
this._previousTestResultId = this.testResultId;
|
|
579
|
-
|
|
580
|
-
if (!this.isAllowReportTestResultRetries()) {
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
this._totalRetryCount++;
|
|
585
|
-
this._originalTestResultId = this._originalTestResultId || this._previousTestResultId;
|
|
586
|
-
this._testResultId = utils.guid();
|
|
587
|
-
|
|
588
|
-
if (this._options.lightweightMode?.onlyTestIdsNoSuite) {
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
await this._testRunStatus.addRetryTestResult({
|
|
593
|
-
retryCount: this._totalRetryCount,
|
|
594
|
-
executionId: this._executionId,
|
|
595
|
-
projectId: this._options.project,
|
|
596
|
-
newResultId: this._testResultId,
|
|
597
|
-
originalTestResultId: this._originalTestResultId,
|
|
598
|
-
previousTestResultId: this._previousTestResultId,
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
module.exports = TestRun;
|