@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/testRunStatus.js
DELETED
|
@@ -1,567 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const _ = require('lodash');
|
|
4
|
-
const utils = require('./utils');
|
|
5
|
-
const reporter = require('./reports/reporter');
|
|
6
|
-
const constants = require('./commons/constants');
|
|
7
|
-
const gridService = require('./services/gridService');
|
|
8
|
-
const featureFlags = require('./commons/featureFlags');
|
|
9
|
-
const servicesApi = require('./commons/testimServicesApi');
|
|
10
|
-
const OverrideTestDataBuilder = require('./OverrideTestDataBuilder');
|
|
11
|
-
const featureAvailabilityService = require('./commons/featureAvailabilityService');
|
|
12
|
-
const { ArgError } = require('./errors');
|
|
13
|
-
const { getLogger } = require('./commons/logger');
|
|
14
|
-
const { registerExitHook } = require('./processHandler');
|
|
15
|
-
const { calculateCoverage } = require('./coverage/jsCoverage');
|
|
16
|
-
const { SeleniumPerfStats } = require('./commons/SeleniumPerfStats');
|
|
17
|
-
const { mapFilesToLocalDrive } = require('./services/localRCASaver');
|
|
18
|
-
const { TESTIM_CONCURRENT_WORKER_COUNT } = require('./commons/config');
|
|
19
|
-
|
|
20
|
-
const logger = getLogger('test-run-status');
|
|
21
|
-
const gitBranch = utils.getEnvironmentGitBranch();
|
|
22
|
-
const gitCommit = process.env.GIT_COMMIT || process.env.CIRCLE_SHA1 || process.env.TRAVIS_COMMIT;
|
|
23
|
-
const gitRepoUrl = process.env.GIT_URL || process.env.CIRCLE_REPOSITORY_URL;
|
|
24
|
-
const runnerVersion = utils.getRunnerVersion();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
async function runHook(fn, ...args) {
|
|
28
|
-
if (!fn || typeof fn !== 'function') {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const res = await fn(...args);
|
|
34
|
-
return res || {};
|
|
35
|
-
} catch (err) {
|
|
36
|
-
logger.warn('failed to run hook', { err });
|
|
37
|
-
throw new ArgError(`failed to run hook promise ${err.message}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
class RunStatus {
|
|
42
|
-
/**
|
|
43
|
-
* @param {any[]} testInfoList
|
|
44
|
-
* @param {import('./runOptions').RunnerOptions} options
|
|
45
|
-
* @param {string} testPlanId
|
|
46
|
-
* @param {string} branchToUse
|
|
47
|
-
*/
|
|
48
|
-
constructor(testInfoList, options, testPlanId, branchToUse) {
|
|
49
|
-
this.options = options;
|
|
50
|
-
this.options.runParams = this.options.runParams || {};
|
|
51
|
-
this.startTime = null;
|
|
52
|
-
this.fileUserParamsData = this.options.userParamsData;
|
|
53
|
-
this.beforeSuiteParams = {};
|
|
54
|
-
this.branchToUse = branchToUse;
|
|
55
|
-
this.exportsGlobal = {};
|
|
56
|
-
this.testInfoList = testInfoList;
|
|
57
|
-
|
|
58
|
-
this.executionStartedPromise = Promise.resolve();
|
|
59
|
-
|
|
60
|
-
const browserNames = utils.getUniqBrowsers(options, testInfoList);
|
|
61
|
-
const runnerMode = options.lightweightMode ? options.lightweightMode.type : options.mode;
|
|
62
|
-
this.execConfig = {
|
|
63
|
-
parallel: TESTIM_CONCURRENT_WORKER_COUNT || options.parallel || 1,
|
|
64
|
-
browser: browserNames,
|
|
65
|
-
gitBranch,
|
|
66
|
-
gitCommit,
|
|
67
|
-
gitRepoUrl,
|
|
68
|
-
runnerVersion,
|
|
69
|
-
gridHost: options.host || options.gridData.host,
|
|
70
|
-
testimBranch: branchToUse,
|
|
71
|
-
canaryMode: options.canary,
|
|
72
|
-
source: options.source,
|
|
73
|
-
schedulerId: options.schedulerId,
|
|
74
|
-
testPlanId,
|
|
75
|
-
testPlans: options.testPlan,
|
|
76
|
-
testLabels: options.label,
|
|
77
|
-
testSuites: [...new Set(testInfoList.flatMap(test => test.testSuites))],
|
|
78
|
-
testNames: options.name,
|
|
79
|
-
testIds: options.testId,
|
|
80
|
-
testConfigs: options.testConfigNames,
|
|
81
|
-
testConfigIds: options.testConfigIds,
|
|
82
|
-
port: options.port,
|
|
83
|
-
browserTimeout: options.browserTimeout,
|
|
84
|
-
timeout: options.timeout,
|
|
85
|
-
newBrowserWaitTimeout: options.newBrowserWaitTimeout,
|
|
86
|
-
tunnel: options.tunnel,
|
|
87
|
-
tunnelPort: options.tunnelPort,
|
|
88
|
-
tunnelHostHeader: options.tunnelHostHeader,
|
|
89
|
-
runnerMode,
|
|
90
|
-
gridId: options.gridId || options.gridData.gridId,
|
|
91
|
-
gridName: options.grid || options.gridData.name,
|
|
92
|
-
gridType: options.gridData.type,
|
|
93
|
-
retentionDays: options.retentionDays,
|
|
94
|
-
codeCoverageReportPath: options.codeCoverageReportPath,
|
|
95
|
-
collectCodeCoverage: options.codeCoverageUrlFilter || options.collectCodeCoverage,
|
|
96
|
-
sessionType: utils.getSessionType(options),
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
this.seleniumPerfStats = new SeleniumPerfStats();
|
|
100
|
-
this.calcTestRunStatus();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
waitForExecutionStartedFinished() {
|
|
104
|
-
return this.executionStartedPromise;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
getTestResult(resultId) {
|
|
108
|
-
return this.testRunStatus[resultId];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
async addRetryTestResult({
|
|
112
|
-
newResultId, originalTestResultId, previousTestResultId, projectId, executionId, retryCount = 1,
|
|
113
|
-
}) {
|
|
114
|
-
const orgTestResult = this.testRunStatus[originalTestResultId] || {};
|
|
115
|
-
const {
|
|
116
|
-
config,
|
|
117
|
-
isTestsContainer,
|
|
118
|
-
testId,
|
|
119
|
-
name,
|
|
120
|
-
testStatus,
|
|
121
|
-
testCreatorName,
|
|
122
|
-
testCreatorEmail,
|
|
123
|
-
testOwnerName,
|
|
124
|
-
testOwnerEmail,
|
|
125
|
-
testLabels,
|
|
126
|
-
testSuites,
|
|
127
|
-
allLabels,
|
|
128
|
-
} = orgTestResult;
|
|
129
|
-
|
|
130
|
-
const newTestResult = {
|
|
131
|
-
originalTestResultId,
|
|
132
|
-
previousTestResultId,
|
|
133
|
-
config: _.cloneDeep(config),
|
|
134
|
-
testId,
|
|
135
|
-
status: 'QUEUED',
|
|
136
|
-
name,
|
|
137
|
-
resultId: newResultId,
|
|
138
|
-
isTestsContainer,
|
|
139
|
-
retryCount,
|
|
140
|
-
testStatus,
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
this.testRunStatus[newResultId] = Object.assign({}, newTestResult, {
|
|
144
|
-
testCreatorName,
|
|
145
|
-
testCreatorEmail,
|
|
146
|
-
testOwnerName,
|
|
147
|
-
testOwnerEmail,
|
|
148
|
-
testLabels,
|
|
149
|
-
testSuites,
|
|
150
|
-
allLabels,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
return servicesApi.addTestRetry({
|
|
154
|
-
projectId,
|
|
155
|
-
runId: executionId,
|
|
156
|
-
testId,
|
|
157
|
-
newResultId,
|
|
158
|
-
originalTestResultId,
|
|
159
|
-
previousTestResultId,
|
|
160
|
-
testResult: newTestResult,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
getAllTestResults() {
|
|
165
|
-
return this.testRunStatus;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
testStart(wid, executionId, resultId, isRerun) {
|
|
169
|
-
const test = this.getTestResult(resultId);
|
|
170
|
-
test.workerId = wid;
|
|
171
|
-
const isCodeMode = this.options.files.length > 0;
|
|
172
|
-
reporter.onTestStarted(test, wid, isRerun, isCodeMode, resultId);
|
|
173
|
-
|
|
174
|
-
return test;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
async updateTestStatusRunning(test, executionId, testRetryKey) {
|
|
178
|
-
const { project: projectId, remoteRunId, projectData } = this.options;
|
|
179
|
-
if (this.options.lightweightMode?.onlyTestIdsNoSuite) {
|
|
180
|
-
return this.executionStartedPromise;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
let testDataUrl = '';
|
|
184
|
-
|
|
185
|
-
try {
|
|
186
|
-
testDataUrl = await servicesApi.updateTestDataArtifact(projectId, test.testId, test.resultId, test.config.testData, projectData.defaults);
|
|
187
|
-
} catch (err) {
|
|
188
|
-
logger.error('failed to upload test data artifact (runner)', { err });
|
|
189
|
-
}
|
|
190
|
-
const testConfig = _.cloneDeep(test.config);
|
|
191
|
-
delete testConfig.testData;
|
|
192
|
-
testConfig.testDataUrl = testDataUrl;
|
|
193
|
-
await this.executionStartedPromise;
|
|
194
|
-
return servicesApi.updateTestStatus(projectId, executionId, test.testId, test.resultId, 'RUNNING', { startTime: test.startTime, config: testConfig, remoteRunId, testRetryKey });
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
async testStartReport(test, executionId, testRetryKey) {
|
|
198
|
-
if (utils.isQuarantineAndNotRemoteRun(test, this.options)) {
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
const globalParameters = this.exportsGlobal;
|
|
202
|
-
try {
|
|
203
|
-
const params = await runHook(this.options.beforeTest, Object.assign({}, test, { exportsGlobal: globalParameters, globalParameters }), this.options.userData.loginData.token);
|
|
204
|
-
|
|
205
|
-
test.config.testData = Object.assign({}, test.config.testData, this.exportsGlobal, this.fileUserParamsData, this.beforeSuiteParams, params);
|
|
206
|
-
this.options.runParams[test.resultId] = test.config.testData;
|
|
207
|
-
test.startTime = Date.now();
|
|
208
|
-
await this.updateTestStatusRunning(test, executionId, testRetryKey);
|
|
209
|
-
|
|
210
|
-
return test;
|
|
211
|
-
} catch (err) {
|
|
212
|
-
logger.error('Failed to start test', { err });
|
|
213
|
-
throw err;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
testStartAndReport(wid, executionId, resultId, isRerun, testRetryKey) {
|
|
218
|
-
const test = this.testStart(wid, executionId, resultId, isRerun);
|
|
219
|
-
return this.testStartReport(test, executionId, testRetryKey);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* @param {string} resultId
|
|
224
|
-
* @param {Awaited<ReturnType<typeof import('./services/gridService')['getGridSlot']>>} gridInfo
|
|
225
|
-
*/
|
|
226
|
-
onGridSlot(resultId, gridInfo) {
|
|
227
|
-
const test = this.getTestResult(resultId);
|
|
228
|
-
test.config.gridInfo = Object.assign({}, gridInfo, { key: undefined, user: undefined });
|
|
229
|
-
logger.info('on get grid info', { gridInfo: test.config.gridInfo });
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
reportTestStatus(workerId, result, test, isRerun) {
|
|
233
|
-
const { name, testId, testStatus } = test;
|
|
234
|
-
const { resultId, success } = result;
|
|
235
|
-
if (testStatus === constants.testStatus.EVALUATING && featureAvailabilityService.isTestStatusEnabled) {
|
|
236
|
-
reporter.onTestIgnored(workerId, test, `test in ${constants.testStatus.EVALUATING} status`);
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
if (success) {
|
|
240
|
-
reporter.onTestPassed(name);
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
reporter.onTestFailed(
|
|
244
|
-
test,
|
|
245
|
-
test.failureReason,
|
|
246
|
-
utils.getTestUrl(this.options.editorUrl, this.options.project, testId, resultId, this.branchToUse),
|
|
247
|
-
testId,
|
|
248
|
-
isRerun,
|
|
249
|
-
resultId,
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
calcResultText(result) {
|
|
254
|
-
return result.success ? constants.runnerTestStatus.PASSED : constants.runnerTestStatus.FAILED;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @param {number} wid
|
|
259
|
-
* @param {Parameters<ConstructorParameters<typeof import('./workers/BaseWorker')>[7]>[1]} resultId
|
|
260
|
-
*/
|
|
261
|
-
onTestIgnored(wid, resultId) {
|
|
262
|
-
const test = this.getTestResult(resultId);
|
|
263
|
-
reporter.onTestIgnored(wid, test, `test in ${constants.testStatus.QUARANTINE}`);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
testEnd(wid, result, executionId, sessionId, isRerun) {
|
|
267
|
-
const test = this.testRunStatus[result.resultId];
|
|
268
|
-
|
|
269
|
-
const duration = (result.endTime - result.startTime) || 0;
|
|
270
|
-
test.sessionId = sessionId;
|
|
271
|
-
test.startTime = result.startTime || test.startTime || Date.now();
|
|
272
|
-
test.duration = duration;
|
|
273
|
-
result.duration = duration;
|
|
274
|
-
test.failureReason = result.failureReason || result.reason;
|
|
275
|
-
result.failureReason = test.failureReason;
|
|
276
|
-
test.failurePath = result.failurePath;
|
|
277
|
-
test.resultId = result.resultId;
|
|
278
|
-
test.success = result.success;
|
|
279
|
-
|
|
280
|
-
if (this.options.saveRCALocally) {
|
|
281
|
-
mapFilesToLocalDrive(test, logger);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
test.resultUrl = utils.getTestUrl(this.options.editorUrl, this.options.project, test.testId, test.resultId, this.branchToUse);
|
|
285
|
-
test.status = this.calcResultText(result);
|
|
286
|
-
|
|
287
|
-
result.status = test.status;
|
|
288
|
-
result.name = test.name;
|
|
289
|
-
result.testStatus = test.testStatus;
|
|
290
|
-
result.testId = result.testId || test.testId;
|
|
291
|
-
result.testCreatorName = test.testCreatorName;
|
|
292
|
-
result.testCreatorEmail = test.testCreatorEmail;
|
|
293
|
-
result.testOwnerName = test.testOwnerName;
|
|
294
|
-
result.testOwnerEmail = test.testOwnerEmail;
|
|
295
|
-
result.testData = test.config && typeof test.config.testDataTotal === 'number' ? {
|
|
296
|
-
total: test.config.testDataTotal,
|
|
297
|
-
index: test.config.testDataIndex,
|
|
298
|
-
} : {};
|
|
299
|
-
|
|
300
|
-
this.reportTestStatus(wid, result, test, isRerun);
|
|
301
|
-
const isCodeMode = this.options.files.length > 0;
|
|
302
|
-
reporter.onTestFinished(test, wid, isRerun, isCodeMode);
|
|
303
|
-
|
|
304
|
-
const afterMerge = Object.assign({}, this.exportsGlobal, result.exportsGlobal);
|
|
305
|
-
|
|
306
|
-
this.exportsGlobal = afterMerge;
|
|
307
|
-
return test;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
async testEndReport(test, executionId, result, testResultUpdates) {
|
|
311
|
-
const globalParameters = result.exportsGlobal;
|
|
312
|
-
try {
|
|
313
|
-
try {
|
|
314
|
-
await runHook(this.options.afterTest, Object.assign({}, test, { exportsGlobal: globalParameters, globalParameters }), this.options.userData.loginData.token);
|
|
315
|
-
} catch (err) {
|
|
316
|
-
logger.error('HOOK threw an error', { test: test.testId, err });
|
|
317
|
-
// eslint-disable-next-line no-console
|
|
318
|
-
console.error('HOOK threw an error', err); // show the customer that his hook failed.
|
|
319
|
-
}
|
|
320
|
-
if (this.options.lightweightMode?.onlyTestIdsNoSuite) {
|
|
321
|
-
return undefined;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
return await servicesApi.updateTestStatus(this.options.project, executionId, test.testId, test.resultId, 'FINISHED', {
|
|
325
|
-
startTime: test.startTime,
|
|
326
|
-
endTime: result.endTime,
|
|
327
|
-
success: test.success,
|
|
328
|
-
failureReason: test.failureReason,
|
|
329
|
-
remoteRunId: this.options.remoteRunId,
|
|
330
|
-
...testResultUpdates,
|
|
331
|
-
}, 5);
|
|
332
|
-
} catch (err) {
|
|
333
|
-
logger.error('Failed to update test finished', { err });
|
|
334
|
-
throw err;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
testEndAndReport(wid, result, executionId, sessionId, isRerun, testResultUpdates) {
|
|
339
|
-
const test = this.testEnd(wid, result, executionId, sessionId, isRerun);
|
|
340
|
-
return this.testEndReport(test, executionId, result, testResultUpdates);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
calcTestRunStatus() {
|
|
344
|
-
const { options, testInfoList } = this;
|
|
345
|
-
const companyId = options.company.companyId;
|
|
346
|
-
this.testRunStatus = testInfoList.reduce((resultStatus, testInfo) => {
|
|
347
|
-
resultStatus[testInfo.resultId] = {
|
|
348
|
-
testId: testInfo.testId,
|
|
349
|
-
status: utils.isQuarantineAndNotRemoteRun(testInfo, options) ? constants.runnerTestStatus.SKIPPED : constants.runnerTestStatus.QUEUED,
|
|
350
|
-
name: testInfo.name,
|
|
351
|
-
resultId: testInfo.resultId,
|
|
352
|
-
isTestsContainer: testInfo.isTestsContainer,
|
|
353
|
-
testStatus: testInfo.testStatus || constants.testStatus.DRAFT,
|
|
354
|
-
testCreatorName: testInfo.creatorName,
|
|
355
|
-
testCreatorEmail: testInfo.creatorEmail,
|
|
356
|
-
testOwnerName: testInfo.testOwnerName,
|
|
357
|
-
testOwnerEmail: testInfo.testOwnerEmail,
|
|
358
|
-
testLabels: testInfo.testLabels,
|
|
359
|
-
testSuites: testInfo.testSuites,
|
|
360
|
-
allLabels: testInfo.allLabels,
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const runConfig = options.browser ? utils.getRunConfigByBrowserName(options.browser, options.saucelabs, options.browserstack) : testInfo.runConfig;
|
|
364
|
-
|
|
365
|
-
if (runConfig && featureFlags.flags.dec2022eolBrowsers.isEnabled() && utils.getBrowserInfo(runConfig.browserValue)?.eol) {
|
|
366
|
-
throw new ArgError(`Unsupported Browser: ${runConfig.browserName}`);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
resultStatus[testInfo.resultId].config = Object.assign({}, this.execConfig, {
|
|
370
|
-
companyId,
|
|
371
|
-
testData: testInfo.testData?.value ? testInfo.testData.value : null,
|
|
372
|
-
});
|
|
373
|
-
resultStatus[testInfo.resultId].config.isBeforeTestPlan = testInfo.isBeforeTestPlan;
|
|
374
|
-
resultStatus[testInfo.resultId].config.isAfterTestPlan = testInfo.isAfterTestPlan;
|
|
375
|
-
resultStatus[testInfo.resultId].config.testDataTotal = testInfo.testData?.total || null;
|
|
376
|
-
resultStatus[testInfo.resultId].config.testDataIndex = testInfo.testData?.index || null;
|
|
377
|
-
resultStatus[testInfo.resultId].config.baseUrl = options.baseUrl || testInfo.baseUrl || testInfo.testConfig.baseUrl;
|
|
378
|
-
resultStatus[testInfo.resultId].config.testConfig = testInfo.overrideTestConfig || testInfo.testConfig;
|
|
379
|
-
resultStatus[testInfo.resultId].config.browser = runConfig.browserValue.toLowerCase();
|
|
380
|
-
return resultStatus;
|
|
381
|
-
}, {});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
async executionStart(executionId, projectId, startTime, testPlanName, testNames) {
|
|
385
|
-
logger.info('execution started', { executionId });
|
|
386
|
-
const { options } = this;
|
|
387
|
-
const { remoteRunId, projectData } = options;
|
|
388
|
-
|
|
389
|
-
registerExitHook(() => Promise.all([
|
|
390
|
-
gridService.keepAlive.end(projectId),
|
|
391
|
-
servicesApi.reportExecutionFinished(
|
|
392
|
-
'ABORTED',
|
|
393
|
-
executionId,
|
|
394
|
-
projectId,
|
|
395
|
-
false,
|
|
396
|
-
undefined,
|
|
397
|
-
remoteRunId,
|
|
398
|
-
undefined,
|
|
399
|
-
),
|
|
400
|
-
]));
|
|
401
|
-
|
|
402
|
-
this.startTime = startTime || Date.now();
|
|
403
|
-
const runHooksProps = {
|
|
404
|
-
projectId,
|
|
405
|
-
executionId,
|
|
406
|
-
...(featureFlags.flags.testNamesToBeforeSuiteHook.isEnabled() && { testNames }),
|
|
407
|
-
};
|
|
408
|
-
const params = await runHook(options.beforeSuite, runHooksProps);
|
|
409
|
-
const overrideTestDataBuilder = new OverrideTestDataBuilder(params, _.cloneDeep(this.testInfoList), projectId);
|
|
410
|
-
this.testInfoList = overrideTestDataBuilder.overrideTestData();
|
|
411
|
-
this.calcTestRunStatus();
|
|
412
|
-
this.beforeSuiteParams = params;
|
|
413
|
-
|
|
414
|
-
const { testInfoList } = this;
|
|
415
|
-
const beforeTests = [];
|
|
416
|
-
const tests = [];
|
|
417
|
-
const afterTests = [];
|
|
418
|
-
for (const test of testInfoList) {
|
|
419
|
-
if (test.isBeforeTestPlan) {
|
|
420
|
-
beforeTests.push(test);
|
|
421
|
-
continue;
|
|
422
|
-
}
|
|
423
|
-
if (test.isAfterTestPlan) {
|
|
424
|
-
afterTests.push(test);
|
|
425
|
-
continue;
|
|
426
|
-
}
|
|
427
|
-
tests.push(test);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
const reportExecutionStarted = async () => {
|
|
431
|
-
const testResults = _.cloneDeep(this.testRunStatus);
|
|
432
|
-
await utils.promiseMap(Object.keys(testResults), async testResultId => {
|
|
433
|
-
const test = testResults[testResultId];
|
|
434
|
-
const testData = test.config?.testData;
|
|
435
|
-
const testId = test.testId;
|
|
436
|
-
const testDataUrl = await servicesApi.updateTestDataArtifact(projectId, testId, testResultId, testData, projectData.defaults);
|
|
437
|
-
if (!testDataUrl) {
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
delete test.config.testData;
|
|
441
|
-
test.config.testDataUrl = testDataUrl;
|
|
442
|
-
});
|
|
443
|
-
const isLocalRun = Boolean(options.useLocalChromeDriver || options.useChromeLauncher);
|
|
444
|
-
const data = {
|
|
445
|
-
executionId,
|
|
446
|
-
projectId,
|
|
447
|
-
labels: testPlanName || [],
|
|
448
|
-
startTime,
|
|
449
|
-
executions: testResults,
|
|
450
|
-
config: this.execConfig,
|
|
451
|
-
resultLabels: options.resultLabels,
|
|
452
|
-
remoteRunId: options.remoteRunId,
|
|
453
|
-
localRunUserId: options.user,
|
|
454
|
-
isLocalRun,
|
|
455
|
-
intersections: options.intersections,
|
|
456
|
-
};
|
|
457
|
-
const ret = servicesApi.reportExecutionStarted(data);
|
|
458
|
-
this.executionStartedPromise = ret;
|
|
459
|
-
ret.catch(e => logger.error(e));
|
|
460
|
-
return ret;
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
try {
|
|
464
|
-
await reportExecutionStarted();
|
|
465
|
-
} catch (err) {
|
|
466
|
-
logger.error('Failed to start suite', { err });
|
|
467
|
-
// eslint-disable-next-line no-console
|
|
468
|
-
console.error('Failed to start test run. Please contact support@testim.io');
|
|
469
|
-
}
|
|
470
|
-
return { beforeTests, tests, afterTests };
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
concatSeleniumPerfMarks(marks) {
|
|
474
|
-
_.chain(marks)
|
|
475
|
-
.keys()
|
|
476
|
-
.each((key) => {
|
|
477
|
-
if (this.seleniumPerfStats.marks[key]) {
|
|
478
|
-
this.seleniumPerfStats.marks[key] = [...this.seleniumPerfStats.marks[key], ...marks[key]];
|
|
479
|
-
}
|
|
480
|
-
})
|
|
481
|
-
.value();
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
async executionEnd(executionId) {
|
|
485
|
-
const tests = utils.groupTestsByRetries(this.testRunStatus);
|
|
486
|
-
const total = tests.length;
|
|
487
|
-
|
|
488
|
-
let passed = 0;
|
|
489
|
-
let skipped = 0;
|
|
490
|
-
let failedInEvaluatingStatus = 0;
|
|
491
|
-
for (const { status, testStatus } of tests) {
|
|
492
|
-
if (status === constants.runnerTestStatus.PASSED) {
|
|
493
|
-
passed++;
|
|
494
|
-
}
|
|
495
|
-
if (status === constants.runnerTestStatus.SKIPPED) {
|
|
496
|
-
skipped++;
|
|
497
|
-
}
|
|
498
|
-
if (status === constants.runnerTestStatus.FAILED && testStatus === constants.testStatus.EVALUATING) {
|
|
499
|
-
failedInEvaluatingStatus++;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
const { seleniumPerfMarks, ...resultExtraData } = this.seleniumPerfStats.getStats();
|
|
504
|
-
|
|
505
|
-
try {
|
|
506
|
-
await runHook(this.options.afterSuite, {
|
|
507
|
-
exportsGlobal: this.exportsGlobal,
|
|
508
|
-
tests,
|
|
509
|
-
total,
|
|
510
|
-
passed,
|
|
511
|
-
skipped,
|
|
512
|
-
});
|
|
513
|
-
} catch (err) {
|
|
514
|
-
// eslint-disable-next-line no-console
|
|
515
|
-
console.log('check your callback handler on afterSuite Hook for syntax or exception errors');
|
|
516
|
-
logger.warn('error while running afterSuite Hook', { err, projectId: this.options.projectData.projectId, executionId: this.options.executionId });
|
|
517
|
-
}
|
|
518
|
-
const coverageSummary = await calculateCoverage(this.options, this.branchToUse, total, executionId);
|
|
519
|
-
resultExtraData.coverageSummary = coverageSummary;
|
|
520
|
-
|
|
521
|
-
if (this.options.lightweightMode?.onlyTestIdsNoSuite) {
|
|
522
|
-
return undefined;
|
|
523
|
-
}
|
|
524
|
-
try {
|
|
525
|
-
return await servicesApi.reportExecutionFinished(
|
|
526
|
-
'FINISHED',
|
|
527
|
-
executionId,
|
|
528
|
-
this.options.project,
|
|
529
|
-
total === (passed + skipped + failedInEvaluatingStatus),
|
|
530
|
-
{
|
|
531
|
-
tmsSuppressReporting: this.options.tmsSuppressReporting,
|
|
532
|
-
tmsRunId: this.options.tmsRunId,
|
|
533
|
-
tmsCustomFields: this.options.tmsCustomFields,
|
|
534
|
-
},
|
|
535
|
-
this.options.remoteRunId,
|
|
536
|
-
resultExtraData,
|
|
537
|
-
);
|
|
538
|
-
} catch (err) {
|
|
539
|
-
logger.error('Failed to update suite finished', { err });
|
|
540
|
-
throw err;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
async markAllQueuedTests(executionId, status, failureReason, success) {
|
|
545
|
-
const queuedResultIds = Object.keys(this.testRunStatus).filter(resultId => this.getTestResult(resultId).status === 'QUEUED');
|
|
546
|
-
|
|
547
|
-
await servicesApi.updateExecutionTests(
|
|
548
|
-
executionId,
|
|
549
|
-
['QUEUED'],
|
|
550
|
-
status,
|
|
551
|
-
failureReason,
|
|
552
|
-
success,
|
|
553
|
-
this.startTime,
|
|
554
|
-
null,
|
|
555
|
-
this.options.project,
|
|
556
|
-
);
|
|
557
|
-
for (const resultId of queuedResultIds) {
|
|
558
|
-
const test = this.getTestResult(resultId);
|
|
559
|
-
test.status = status;
|
|
560
|
-
test.failureReason = failureReason;
|
|
561
|
-
test.success = success;
|
|
562
|
-
}
|
|
563
|
-
return this.testRunStatus;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
module.exports = RunStatus;
|
package/testimNpmDriver.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-console */
|
|
4
|
-
const semver = require('semver');
|
|
5
|
-
const config = require('./commons/config');
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const logger = require('./commons/logger').getLogger('npm-driver');
|
|
8
|
-
const localRunnerCache = require('./commons/runnerFileCache');
|
|
9
|
-
const npmWrapper = require('./commons/npmWrapper');
|
|
10
|
-
const chalk = require('chalk');
|
|
11
|
-
const utils = require('./utils');
|
|
12
|
-
|
|
13
|
-
const getNpmVersion = localRunnerCache.memoize(() => npmWrapper.getLatestPackageVersion('@testim/testim-cli'), 'getNpmVersion');
|
|
14
|
-
|
|
15
|
-
function getPackageVersion() {
|
|
16
|
-
try {
|
|
17
|
-
logger.debug('Get package version');
|
|
18
|
-
const path = `${__dirname}/package.json`;
|
|
19
|
-
if (!fs.existsSync(path)) {
|
|
20
|
-
// This usually means that the program runs from a dev environment (in which __dirname
|
|
21
|
-
// is the src/ directory which, obviously, does not contain a package.json file).
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
const packageJson = require(path);
|
|
25
|
-
return packageJson.version;
|
|
26
|
-
} catch (err) {
|
|
27
|
-
logger.warn('Failed to get package version', { err });
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function checkNpmVersion() {
|
|
33
|
-
if (config.IS_ON_PREM) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
const latestVersion = await utils.promiseTimeout(getNpmVersion(), 5000, 'The API call to NPM timed out');
|
|
38
|
-
const packVersion = getPackageVersion();
|
|
39
|
-
if (packVersion && semver.lt(packVersion, latestVersion)) {
|
|
40
|
-
console.log(chalk.yellow(
|
|
41
|
-
`Warning: You are using version ${packVersion}, a newer version is available. To update please run npm install (npm install -g @testim/testim-cli)`)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
} catch (err) {
|
|
45
|
-
logger.warn('Failed to get NPM version', { err });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
module.exports = {
|
|
50
|
-
checkNpmVersion,
|
|
51
|
-
getPackageVersion,
|
|
52
|
-
};
|