@testim/testim-cli 3.289.0 → 3.290.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.
- package/cli.js +22390 -122
- package/cli.js.map +1 -0
- package/npm-shrinkwrap.json +1951 -203
- package/package.json +9 -5
- 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
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
const { expect, sinon } = require('../../test/utils/testUtils');
|
|
2
|
-
const servicesApi = require('../commons/testimServicesApi');
|
|
3
|
-
const httpRequest = require('../commons/httpRequest');
|
|
4
|
-
const LambdatestService = require('./lambdatestService');
|
|
5
|
-
const utils = require('../utils');
|
|
6
|
-
const fse = require('fs-extra');
|
|
7
|
-
const { AbortError } = require('p-retry');
|
|
8
|
-
const os = require('os');
|
|
9
|
-
const childProcess = require('child_process');
|
|
10
|
-
const EventEmitter = require('events');
|
|
11
|
-
const portfinder = require('portfinder');
|
|
12
|
-
const { getExtensionsUrl } = require('../runOptionsUtils');
|
|
13
|
-
|
|
14
|
-
class Process extends EventEmitter {
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
this.stdout = new EventEmitter();
|
|
18
|
-
this.stderr = new EventEmitter();
|
|
19
|
-
}
|
|
20
|
-
setCode(code) {
|
|
21
|
-
this.code = code;
|
|
22
|
-
}
|
|
23
|
-
kill() {
|
|
24
|
-
this.emit('close', this.code);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
describe('LambdatestService', () => {
|
|
29
|
-
let sandbox;
|
|
30
|
-
let lambdatestService;
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
lambdatestService = new LambdatestService();
|
|
33
|
-
sandbox = sinon.createSandbox();
|
|
34
|
-
});
|
|
35
|
-
afterEach(() => {
|
|
36
|
-
sandbox.restore();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('isLambdatestGrid', () => {
|
|
40
|
-
it('should consider a lambda test grid as a lambda test grid', () => {
|
|
41
|
-
expect(LambdatestService.isLambdatestGrid({ type: 'testimLambdaTest' })).to.be.true;
|
|
42
|
-
});
|
|
43
|
-
it('should consider a hybrid grid as a lambda test grid according to ist provider', () => {
|
|
44
|
-
expect(LambdatestService.isLambdatestGrid({ type: 'testimHybrid', provider: 'lambdatest' })).to.be.true;
|
|
45
|
-
expect(LambdatestService.isLambdatestGrid({ type: 'testimHybrid', provider: 'other' })).to.be.false;
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('isLambdatestRun', () => {
|
|
50
|
-
it('should consider a lambda test run as a lambda test run', () => {
|
|
51
|
-
lambdatestService.isActive = true;
|
|
52
|
-
expect(lambdatestService.isLambdatestRun()).to.be.true;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should consider non lambda test run as non lambda test run', () => {
|
|
56
|
-
lambdatestService.isActive = false;
|
|
57
|
-
expect(lambdatestService.isLambdatestRun()).to.be.false;
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe('enableIfNeeded', () => {
|
|
62
|
-
let fetchLambdatestConfigStub;
|
|
63
|
-
beforeEach(() => {
|
|
64
|
-
fetchLambdatestConfigStub = sinon.stub(servicesApi, 'fetchLambdatestConfig').resolves({});
|
|
65
|
-
});
|
|
66
|
-
afterEach(() => {
|
|
67
|
-
fetchLambdatestConfigStub.restore();
|
|
68
|
-
delete LambdatestService.lambdatestConfigPromise;
|
|
69
|
-
delete LambdatestService.lambdatestConfig;
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should not enable lambdatest for non lt grid', async () => {
|
|
73
|
-
await lambdatestService.enableIfNeeded({});
|
|
74
|
-
expect(lambdatestService.isActive).to.be.false;
|
|
75
|
-
sinon.assert.notCalled(fetchLambdatestConfigStub);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should enable lambdatest for lt grid', async () => {
|
|
79
|
-
await lambdatestService.enableIfNeeded({ type: 'testimLambdaTest' });
|
|
80
|
-
expect(lambdatestService.isActive).to.be.true;
|
|
81
|
-
sinon.assert.calledOnce(fetchLambdatestConfigStub);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should enable lambdatest for hybrid grid with lt provider', async () => {
|
|
85
|
-
await lambdatestService.enableIfNeeded({ type: 'testimHybrid', provider: 'lambdatest' });
|
|
86
|
-
expect(lambdatestService.isActive).to.be.true;
|
|
87
|
-
sinon.assert.calledOnce(fetchLambdatestConfigStub);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should not enable lambdatest for hybrid grid with other provider', async () => {
|
|
91
|
-
await lambdatestService.enableIfNeeded({ type: 'testimHybrid', provider: 'other' });
|
|
92
|
-
expect(lambdatestService.isActive).to.be.false;
|
|
93
|
-
sinon.assert.notCalled(fetchLambdatestConfigStub);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('should cache lambdatest config', async () => {
|
|
97
|
-
await lambdatestService.enableIfNeeded({ type: 'testimLambdaTest' });
|
|
98
|
-
await lambdatestService.enableIfNeeded({ type: 'testimLambdaTest' });
|
|
99
|
-
sinon.assert.calledOnce(fetchLambdatestConfigStub);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe('specific lt capabilities', () => {
|
|
104
|
-
it('should return lt session timeout for lt grid', async () => {
|
|
105
|
-
lambdatestService.isActive = true;
|
|
106
|
-
expect(lambdatestService.getSessionTimeout).to.be.equal(900000);
|
|
107
|
-
lambdatestService.isActive = false;
|
|
108
|
-
expect(lambdatestService.getSessionTimeout).to.be.equal(null);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should return lt session retries for lt grid', async () => {
|
|
112
|
-
lambdatestService.isActive = true;
|
|
113
|
-
expect(lambdatestService.getSessionRetries).to.be.equal(1);
|
|
114
|
-
lambdatestService.isActive = false;
|
|
115
|
-
expect(lambdatestService.getSessionRetries).to.be.equal(null);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('should not return lt special selenium capabilities when inactove', () => {
|
|
119
|
-
lambdatestService.isActive = false;
|
|
120
|
-
expect(lambdatestService.getCapabilities({})).to.eql({});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should return lt selenium capabilities', () => {
|
|
124
|
-
const browser = utils.guid();
|
|
125
|
-
const executionId = utils.guid();
|
|
126
|
-
const testResultId = utils.guid();
|
|
127
|
-
const testName = utils.guid();
|
|
128
|
-
|
|
129
|
-
lambdatestService.isActive = true;
|
|
130
|
-
LambdatestService.lambdatestConfig = {
|
|
131
|
-
CAPABILITIES: { [browser]: { specificBrowserCaps: 123 } },
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
expect(lambdatestService.getCapabilities({}, browser, executionId, testResultId, testName)).to.shallowDeepEqual({
|
|
135
|
-
build: executionId,
|
|
136
|
-
name: `${testResultId} - ${testName}`,
|
|
137
|
-
platform: LambdatestService.lambdatestConfig.PLATFORM,
|
|
138
|
-
// eslint-disable-next-line camelcase
|
|
139
|
-
selenium_version: LambdatestService.lambdatestConfig.SELENIUM_VERSION,
|
|
140
|
-
resolution: LambdatestService.lambdatestConfig.RESOLUTION,
|
|
141
|
-
timezone: LambdatestService.lambdatestConfig.TIMEZONE,
|
|
142
|
-
specificBrowserCaps: 123,
|
|
143
|
-
console: true,
|
|
144
|
-
queueTimeout: 300,
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('should return lt tunnel name as part of selenium capabilities', () => {
|
|
149
|
-
lambdatestService.isActive = true;
|
|
150
|
-
LambdatestService.lambdatestConfig = { CAPABILITIES: {} };
|
|
151
|
-
LambdatestService.tunnelName = utils.guid();
|
|
152
|
-
|
|
153
|
-
expect(lambdatestService.getCapabilities({})).to.shallowDeepEqual({
|
|
154
|
-
tunnel: true,
|
|
155
|
-
tunnelName: LambdatestService.tunnelName,
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('should load testim extension when it is not set', () => {
|
|
160
|
-
lambdatestService.isActive = true;
|
|
161
|
-
LambdatestService.lambdatestConfig = { CAPABILITIES: {} };
|
|
162
|
-
LambdatestService.tunnelName = utils.guid();
|
|
163
|
-
|
|
164
|
-
expect(lambdatestService.getCapabilities({ mode: 'extension' }, 'chrome')).to.shallowDeepEqual({ loadExtension: [getExtensionsUrl({}, true).chrome] });
|
|
165
|
-
expect(lambdatestService.getCapabilities({ mode: 'extension' }, 'somOtherBrowser')).to.shallowDeepEqual({ loadExtension: [] });
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should load testim extension when passing extensionPath flag', () => {
|
|
169
|
-
lambdatestService.isActive = true;
|
|
170
|
-
LambdatestService.lambdatestConfig = { CAPABILITIES: {} };
|
|
171
|
-
LambdatestService.tunnelName = utils.guid();
|
|
172
|
-
|
|
173
|
-
const extensionPath = 'http://localhost:1234/extension.zip';
|
|
174
|
-
expect(lambdatestService.getCapabilities({ mode: 'extension', extensionPath })).to.shallowDeepEqual({ loadExtension: [extensionPath] });
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should load testim extension when passing installCustomExtension flag', () => {
|
|
178
|
-
lambdatestService.isActive = true;
|
|
179
|
-
LambdatestService.lambdatestConfig = { CAPABILITIES: {} };
|
|
180
|
-
LambdatestService.tunnelName = utils.guid();
|
|
181
|
-
|
|
182
|
-
const installCustomExtension = 'http://localhost:1234/extension.zip';
|
|
183
|
-
expect(lambdatestService.getCapabilities({ mode: 'extension', installCustomExtension })).to.shallowDeepEqual({ loadExtension: [installCustomExtension] });
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe('prepareTunnel', () => {
|
|
188
|
-
it('should do nothing when tunnel binary already exists', async () => {
|
|
189
|
-
sandbox.stub(fse, 'pathExists').resolves(true);
|
|
190
|
-
const chmod = sandbox.stub(fse, 'chmodSync');
|
|
191
|
-
await LambdatestService.prepareTunnel();
|
|
192
|
-
expect(chmod).not.to.have.been.called;
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('should throw when unsupported os', async () => {
|
|
196
|
-
sandbox.stub(fse, 'pathExists').resolves(false);
|
|
197
|
-
sandbox.stub(os, 'platform').returns('wtf');
|
|
198
|
-
sandbox.stub(os, 'arch').returns('wtf');
|
|
199
|
-
|
|
200
|
-
await expect(LambdatestService.prepareTunnel()).to.be.rejectedWith(Error, 'tunnel on wtfwtf platform is not supported.');
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('should download and extract tunnel binary', async () => {
|
|
204
|
-
sandbox.stub(fse, 'pathExists').resolves(false);
|
|
205
|
-
sandbox.stub(os, 'platform').returns('win32');
|
|
206
|
-
sandbox.stub(os, 'arch').returns('x64');
|
|
207
|
-
|
|
208
|
-
const download = sandbox.stub(utils, 'downloadAndSave');
|
|
209
|
-
const unzip = sandbox.stub(utils, 'unzipFile').resolves();
|
|
210
|
-
|
|
211
|
-
await LambdatestService.prepareTunnel();
|
|
212
|
-
sinon.assert.calledOnce(unzip);
|
|
213
|
-
sinon.assert.calledOnce(download);
|
|
214
|
-
expect(download.args[0][0]).to.startWith('https://downloads.lambdatest.com/tunnel/');
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
describe('connectTunnel', () => {
|
|
219
|
-
let prepareTunnelStub;
|
|
220
|
-
let spawnStub;
|
|
221
|
-
let credentials;
|
|
222
|
-
let httpGetStub;
|
|
223
|
-
let processMock;
|
|
224
|
-
|
|
225
|
-
beforeEach(() => {
|
|
226
|
-
processMock = new Process();
|
|
227
|
-
credentials = { gridUsername: utils.guid(), gridPassword: utils.guid() };
|
|
228
|
-
sandbox.stub(portfinder, 'getPortPromise').resolves(1234);
|
|
229
|
-
prepareTunnelStub = sandbox.stub(LambdatestService, 'prepareTunnel');
|
|
230
|
-
spawnStub = sandbox.stub(childProcess, 'spawn').returns(processMock);
|
|
231
|
-
httpGetStub = sandbox.stub(httpRequest, 'get').resolves({});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('should do nothing when using externalLambdatestTunnelId', async () => {
|
|
235
|
-
await LambdatestService.connectTunnel({ externalLambdatestTunnelId: 123 });
|
|
236
|
-
sinon.assert.neverCalledWith(prepareTunnelStub);
|
|
237
|
-
sinon.assert.neverCalledWith(spawnStub);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it('should prepare the tunnel', async () => {
|
|
241
|
-
await LambdatestService.connectTunnel({ ...credentials });
|
|
242
|
-
sinon.assert.calledOnce(prepareTunnelStub);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('should reject when no credentials', async () => {
|
|
246
|
-
await expect(LambdatestService.connectTunnel({ })).to.be.rejectedWith(Error, 'tunnel requires username and password');
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it('should spawn the tunnel process', async () => {
|
|
250
|
-
await LambdatestService.connectTunnel({ ...credentials });
|
|
251
|
-
sinon.assert.calledOnce(spawnStub);
|
|
252
|
-
expect(spawnStub.args[0][1]).to.eql([
|
|
253
|
-
'--tunnelName', LambdatestService.tunnelName, '--infoAPIPort', 1234,
|
|
254
|
-
'--user', credentials.gridUsername, '--key', credentials.gridPassword,
|
|
255
|
-
]);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('should accept tunnelUser and tunnelKey on gridData', async () => {
|
|
259
|
-
credentials = { gridData: { tunnelUser: utils.guid(), tunnelKey: utils.guid() } };
|
|
260
|
-
await LambdatestService.connectTunnel({ ...credentials });
|
|
261
|
-
sinon.assert.calledOnce(spawnStub);
|
|
262
|
-
expect(spawnStub.args[0][1]).to.eql([
|
|
263
|
-
'--tunnelName', LambdatestService.tunnelName, '--infoAPIPort', 1234,
|
|
264
|
-
'--user', credentials.gridData.tunnelUser, '--key', credentials.gridData.tunnelKey,
|
|
265
|
-
]);
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('should allow using externalLambdatestUseWss', async () => {
|
|
269
|
-
await LambdatestService.connectTunnel({ ...credentials, externalLambdatestUseWss: true });
|
|
270
|
-
sinon.assert.calledOnce(spawnStub);
|
|
271
|
-
expect(spawnStub.args[0][1].join(' ')).to.contain('--mode ws');
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
it('should allow using proxyUri', async () => {
|
|
275
|
-
global.proxyUri = 'http://localhost';
|
|
276
|
-
await LambdatestService.connectTunnel({ ...credentials });
|
|
277
|
-
sinon.assert.calledOnce(spawnStub);
|
|
278
|
-
expect(spawnStub.args[0][1].join(' ')).to.contain('--proxy-host localhost');
|
|
279
|
-
global.proxyUri = undefined;
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('should allow using proxyUri port and credentials', async () => {
|
|
283
|
-
global.proxyUri = 'http://user:pass@localhost:1234';
|
|
284
|
-
await LambdatestService.connectTunnel({ ...credentials });
|
|
285
|
-
sinon.assert.calledOnce(spawnStub);
|
|
286
|
-
expect(spawnStub.args[0][1].join(' ')).to.contain('--proxy-host localhost');
|
|
287
|
-
expect(spawnStub.args[0][1].join(' ')).to.contain('--proxy-port 1234');
|
|
288
|
-
expect(spawnStub.args[0][1].join(' ')).to.contain('--proxy-user user');
|
|
289
|
-
expect(spawnStub.args[0][1].join(' ')).to.contain('--proxy-pass pass');
|
|
290
|
-
global.proxyUri = undefined;
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it('should throw when proxyUri is invalid', async () => {
|
|
294
|
-
global.proxyUri = 'i am invalid';
|
|
295
|
-
await expect(LambdatestService.connectTunnel({ ...credentials })).to.be.rejectedWith(Error, 'proxy url is invalid');
|
|
296
|
-
global.proxyUri = undefined;
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('should allow using externalLambdatestDisableAutomationTunneling', async () => {
|
|
300
|
-
await LambdatestService.connectTunnel({ ...credentials, externalLambdatestDisableAutomationTunneling: true });
|
|
301
|
-
sinon.assert.calledOnce(spawnStub);
|
|
302
|
-
expect(spawnStub.args[0][1].join(' ')).to.contain('--bypassHosts run.testim.io,services.testim.io,api.coralogix.com,conf.rollout.io,statestore.rollout.io,push.rollout.io,analytic.rollout.io,res.cloudinary.com');
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it('should allow using externalLambdatestMitm', async () => {
|
|
306
|
-
await LambdatestService.connectTunnel({ ...credentials, externalLambdatestMitm: true });
|
|
307
|
-
sinon.assert.calledOnce(spawnStub);
|
|
308
|
-
expect(spawnStub.args[0][1].join(' ')).to.contain('--mitm');
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('should verify tunnel started', async () => {
|
|
312
|
-
await LambdatestService.connectTunnel({ ...credentials });
|
|
313
|
-
sinon.assert.calledOnce(httpGetStub);
|
|
314
|
-
});
|
|
315
|
-
it('should throw when tunnel did not start', async () => {
|
|
316
|
-
httpGetStub.rejects(new AbortError('tunnel did not start'));
|
|
317
|
-
await expect(LambdatestService.connectTunnel({ ...credentials })).to.be.rejectedWith(Error, 'tunnel did not start');
|
|
318
|
-
processMock.stdout.emit('data', '');
|
|
319
|
-
processMock.stderr.emit('data', '');
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
describe('disconnectTunnel', () => {
|
|
324
|
-
let processMock;
|
|
325
|
-
let killStub;
|
|
326
|
-
|
|
327
|
-
beforeEach(() => {
|
|
328
|
-
processMock = new Process();
|
|
329
|
-
killStub = sandbox.stub(processMock, 'kill').callThrough();
|
|
330
|
-
sandbox.stub(childProcess, 'spawn').returns(processMock);
|
|
331
|
-
sandbox.stub(LambdatestService, 'prepareTunnel');
|
|
332
|
-
sandbox.stub(httpRequest, 'get').resolves({});
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it('should kill the tunnel', async () => {
|
|
336
|
-
await LambdatestService.connectTunnel({ tunnel: true, company: {}, gridUsername: utils.guid(), gridPassword: utils.guid() });
|
|
337
|
-
await LambdatestService.disconnectTunnel({ company: {} });
|
|
338
|
-
sinon.assert.calledOnce(killStub);
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it('should reject when killing the tunnel fails', async () => {
|
|
342
|
-
processMock.setCode(1);
|
|
343
|
-
await LambdatestService.connectTunnel({ tunnel: true, company: {}, gridUsername: utils.guid(), gridPassword: utils.guid() });
|
|
344
|
-
await expect(LambdatestService.disconnectTunnel({ company: {} })).to.be.rejectedWith(Error);
|
|
345
|
-
sinon.assert.calledOnce(killStub);
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
it('should do nothing when using externalLambdatestTunnelId', async () => {
|
|
349
|
-
await LambdatestService.disconnectTunnel({ externalLambdatestTunnelId: 123 });
|
|
350
|
-
sinon.assert.neverCalledWith(killStub);
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
});
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
const { ArgError } = require('../errors');
|
|
2
|
-
const express = require('express');
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const lazyRequire = require('../commons/lazyRequire');
|
|
7
|
-
|
|
8
|
-
const DEFUALT_PATH = path.join(os.tmpdir(), 'testim/rca/');
|
|
9
|
-
|
|
10
|
-
const stepFileMap = {};
|
|
11
|
-
const resultFileMap = {};
|
|
12
|
-
|
|
13
|
-
const TYPE_RENAMES = {
|
|
14
|
-
'test-log': 'consoleLogs',
|
|
15
|
-
'har-file': 'networkLogs',
|
|
16
|
-
};
|
|
17
|
-
const TYPES = Object.keys(TYPE_RENAMES);
|
|
18
|
-
|
|
19
|
-
function mapFilesToLocalDrive(test, logger) {
|
|
20
|
-
try {
|
|
21
|
-
test.failurePath = (test.failurePath || []).map(f => Object.assign(f, stepFileMap[f.id] ? { screenshot: stepFileMap[f.id] } : {}));
|
|
22
|
-
Object.keys(resultFileMap).forEach(type => {
|
|
23
|
-
test.assets = test.assets || {};
|
|
24
|
-
test.assets[TYPE_RENAMES[type]] = resultFileMap[type];
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test.assets = test.assets || {};
|
|
28
|
-
test.assets.screenshots = Object.values(stepFileMap);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
if (logger) {
|
|
31
|
-
logger.error('failed to map files to local drive', { err });
|
|
32
|
-
}
|
|
33
|
-
// set default values.
|
|
34
|
-
test.failurePath = test.failurePath || [];
|
|
35
|
-
test.assets = test.assets || {};
|
|
36
|
-
test.assets.screenshots = test.assets.screenshots || [];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @param {Partial<Pick<import('../runOptions').AgentModeOptions, 'agentPort' | 'agentBind'> & Pick<import('../runOptions').RunnerOptions, 'saveRCALocally'>>} param0
|
|
42
|
-
* @returns {Promise<import('net').AddressInfo>}
|
|
43
|
-
*/
|
|
44
|
-
async function initServer({ agentPort, agentBind, saveRCALocally }) {
|
|
45
|
-
const multer = await lazyRequire('multer');
|
|
46
|
-
saveRCALocally = typeof saveRCALocally === 'string' ? saveRCALocally : DEFUALT_PATH;
|
|
47
|
-
|
|
48
|
-
await fs.mkdirp(saveRCALocally);
|
|
49
|
-
|
|
50
|
-
const upload = multer({
|
|
51
|
-
storage: multer.diskStorage({
|
|
52
|
-
async destination(req, file, cb) {
|
|
53
|
-
const metadata = JSON.parse(req.body.metadata || '{}');
|
|
54
|
-
if (!metadata.testResultId) {
|
|
55
|
-
return cb(new Error('missing testResultId'));
|
|
56
|
-
}
|
|
57
|
-
const destination = path.join(saveRCALocally, metadata.testResultId);
|
|
58
|
-
try {
|
|
59
|
-
await fs.mkdirp(destination);
|
|
60
|
-
} catch (err) {
|
|
61
|
-
return cb(err);
|
|
62
|
-
}
|
|
63
|
-
return cb(null, destination);
|
|
64
|
-
},
|
|
65
|
-
filename(req, file, cb) {
|
|
66
|
-
const { fileName } = req.body;
|
|
67
|
-
const metadata = JSON.parse(req.body.metadata || '{}');
|
|
68
|
-
if (!metadata.stepId && !fileName) {
|
|
69
|
-
return cb(new Error('missing stepId or fileName'));
|
|
70
|
-
}
|
|
71
|
-
if (metadata.stepId) {
|
|
72
|
-
const format = path.extname(fileName);
|
|
73
|
-
return cb(null, `step_${metadata.stepId}_${metadata.stepName || ''}${format}`.replace(/[/\\?%*:|"<>\s]/g, '-'));
|
|
74
|
-
}
|
|
75
|
-
return cb(null, fileName);
|
|
76
|
-
},
|
|
77
|
-
}),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const app = express();
|
|
81
|
-
|
|
82
|
-
app.post('/', upload.single('file'), (req, res) => {
|
|
83
|
-
const metadata = JSON.parse(req.body.metadata || '{}');
|
|
84
|
-
if (metadata.stepId) {
|
|
85
|
-
stepFileMap[metadata.stepId] = req.file.path;
|
|
86
|
-
}
|
|
87
|
-
if (metadata.testResultId && TYPES.includes(metadata.subType)) {
|
|
88
|
-
resultFileMap[metadata.subType] = resultFileMap[metadata.subType] || [];
|
|
89
|
-
resultFileMap[metadata.subType].push(req.file.path);
|
|
90
|
-
}
|
|
91
|
-
res.sendStatus(200);
|
|
92
|
-
});
|
|
93
|
-
app.use((req, res) => res.status(404).send('Endpoint Not Found'));
|
|
94
|
-
|
|
95
|
-
return await new Promise((resolve, reject) => {
|
|
96
|
-
const http = require('http');
|
|
97
|
-
const server = http.createServer(app);
|
|
98
|
-
server.listen(agentPort, agentBind);
|
|
99
|
-
server.on('error', onError);
|
|
100
|
-
server.on('listening', () => resolve(server.address()));
|
|
101
|
-
|
|
102
|
-
function onError(error) {
|
|
103
|
-
if (error.syscall !== 'listen') {
|
|
104
|
-
return reject(error);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// handle specific listen errors with friendly messages
|
|
108
|
-
switch (error.code) {
|
|
109
|
-
case 'EACCES':
|
|
110
|
-
case 'EPERM':
|
|
111
|
-
return reject(new ArgError(`Port ${agentPort} requires elevated privileges`));
|
|
112
|
-
case 'EADDRINUSE':
|
|
113
|
-
return reject(new ArgError(`Port ${agentPort} is already in use`));
|
|
114
|
-
default:
|
|
115
|
-
return reject(error);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
module.exports = {
|
|
122
|
-
initServer,
|
|
123
|
-
mapFilesToLocalDrive,
|
|
124
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const service = require('../agent/routers/cliJsCode/service');
|
|
4
|
-
const { TimeoutError } = require('../errors');
|
|
5
|
-
const featureFlags = require('../commons/featureFlags');
|
|
6
|
-
|
|
7
|
-
function isExceedingMaxResultSize(data, project) {
|
|
8
|
-
try {
|
|
9
|
-
const shouldEnforceMaxSize = project.defaults.enforceMaximumJsResultSize;
|
|
10
|
-
const maximumJsResultSize = featureFlags.flags.maximumJsResultSize.getValue();
|
|
11
|
-
const dataSizeExceeded = JSON.stringify(data).length > maximumJsResultSize;
|
|
12
|
-
if (!shouldEnforceMaxSize) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return dataSizeExceeded;
|
|
16
|
-
} catch (e) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports.run = async (browser, step, projectData) => {
|
|
22
|
-
const {
|
|
23
|
-
code, stepId, incomingParams, context, testResultId, retryIndex, stepResultId, runTimeout, fileDataUrl, s3filepath,
|
|
24
|
-
} = step.data;
|
|
25
|
-
try {
|
|
26
|
-
const data = await service.runCodeWithPackages(code, stepId, incomingParams, context, testResultId, retryIndex, stepResultId, runTimeout, fileDataUrl, s3filepath);
|
|
27
|
-
if (data && isExceedingMaxResultSize({ result: data.result, tstConsoleLogs: data.tstConsoleLogs }, projectData)) {
|
|
28
|
-
return {
|
|
29
|
-
code: 'js-result-max-size-exceeded',
|
|
30
|
-
success: false,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return { data, success: true };
|
|
34
|
-
} catch (err) {
|
|
35
|
-
if (err instanceof TimeoutError) {
|
|
36
|
-
throw new Error('Timeout while running action');
|
|
37
|
-
}
|
|
38
|
-
throw err;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const MemoryFS = require('memory-fs');
|
|
4
|
-
const AbortController = require('abort-controller');
|
|
5
|
-
const perfLogger = require('../commons/performance-logger');
|
|
6
|
-
const { getLogger } = require('../commons/logger');
|
|
7
|
-
const { sessionType } = require('../commons/constants');
|
|
8
|
-
|
|
9
|
-
const mfs = new MemoryFS();
|
|
10
|
-
const logger = getLogger('hybrid-step-playback');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @type {Map<string, import("abort-controller")>}
|
|
14
|
-
*/
|
|
15
|
-
const runningStepsAbortControllersRegistry = new Map();
|
|
16
|
-
|
|
17
|
-
// TODO(Benji) cache compile between runs with webpack cache plugin or runnerFileCache
|
|
18
|
-
/** @type {import('clickim/src/background/session/code-session-player').CodeSessionPlayer['proxy'] | undefined} */
|
|
19
|
-
let stepsProxy;
|
|
20
|
-
|
|
21
|
-
module.exports.run = (driver, remoteStep, projectData, userData) => {
|
|
22
|
-
const { step, context } = remoteStep.data;
|
|
23
|
-
return module.exports.execute(step, context, driver, userData.loginData);
|
|
24
|
-
// (step, context, driver, loginData, frameManager)
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// this function is exported as a "make sense API", `run` above is teh remote run signature for polymorphic dispatch
|
|
28
|
-
module.exports.execute = async function execute(step, context, driver, loginData, frameManager, source = 'cli') {
|
|
29
|
-
const abortController = new AbortController();
|
|
30
|
-
const { signal: abortSignal } = abortController;
|
|
31
|
-
|
|
32
|
-
runningStepsAbortControllersRegistry.set(context.stepResultId, abortController);
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
perfLogger.log('before seleniumTestPlayer require');
|
|
36
|
-
const SeleniumTestPlayer = require('../player/seleniumTestPlayer');
|
|
37
|
-
const { compileFunctionsLibrary } = require('../agent/routers/codim/service');
|
|
38
|
-
|
|
39
|
-
const { functionName } = step;
|
|
40
|
-
const userParamsData = {}; // no tdk access
|
|
41
|
-
//TODO (benji) read function parameters and arguments from context.incomingParams.as
|
|
42
|
-
const shouldMonitorPerformance = false;
|
|
43
|
-
const player = new SeleniumTestPlayer(
|
|
44
|
-
context.id, // has to be on the same session ID to reuse the same tabs from tabService
|
|
45
|
-
userParamsData,
|
|
46
|
-
shouldMonitorPerformance,
|
|
47
|
-
sessionType.CODEFUL,
|
|
48
|
-
driver,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
stepsProxy = player.sessionPlayer.codeSessionPlayer.proxy;
|
|
52
|
-
// reuse the same memory filesystem between runs for cache
|
|
53
|
-
|
|
54
|
-
const bypassWebpack = step.bypassWebpack ? { testim: stepsProxy.wrappedSteps() } : false;
|
|
55
|
-
|
|
56
|
-
perfLogger.log('before compileFunctionsLibrary', { bypassWebpack: Boolean(step.bypassWebpack) });
|
|
57
|
-
let code;
|
|
58
|
-
try {
|
|
59
|
-
code = await compileFunctionsLibrary({ fileSystem: mfs, bypassWebpack }, abortSignal);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
return { success: false, shouldRetry: false, reason: `Unable to compile functions library. ${e.message}`, extraInfo: e.stack };
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (typeof globalThis === 'undefined') { // fix for Node 8 and Node 10
|
|
65
|
-
global.globalThis = process;
|
|
66
|
-
}
|
|
67
|
-
let hybridFunction;
|
|
68
|
-
if (!bypassWebpack) {
|
|
69
|
-
global.globalThis.__testim = stepsProxy.wrappedSteps();
|
|
70
|
-
// this evaluates the code while exposing __testim. We manually expose the proxy here since
|
|
71
|
-
// our test-extractor code assumes it's extracting tests and this just needs to "eval" the whole file
|
|
72
|
-
(0, eval)(code); // eslint-disable-line no-eval
|
|
73
|
-
hybridFunction = globalThis.tdk[functionName];
|
|
74
|
-
} else {
|
|
75
|
-
hybridFunction = code[functionName];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
perfLogger.log('after hybridFunction obtain and eval');
|
|
79
|
-
if (!hybridFunction) {
|
|
80
|
-
return {
|
|
81
|
-
success: false,
|
|
82
|
-
shouldRetry: false,
|
|
83
|
-
reason: `Could not find function '${functionName}' locally. Please make sure you have a functions.js file with a '${functionName}' function defined`,
|
|
84
|
-
extraInfo: Object.keys(globalThis.tdk), // log available functions to make debugging easier
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (hybridFunction.type === 'selenium') {
|
|
89
|
-
const seleniumPlayback = require('./seleniumHybridStepPlayback').execute;
|
|
90
|
-
return await seleniumPlayback(player, hybridFunction, step, context, source, abortSignal);
|
|
91
|
-
}
|
|
92
|
-
if (hybridFunction.type === 'puppeteer') {
|
|
93
|
-
if (!player.driver.cdpUrl) {
|
|
94
|
-
return { success: false, shouldRetry: false, reason: 'running puppeteer code requires the remote debugging protocol to be open. Please contact Testim support.' };
|
|
95
|
-
}
|
|
96
|
-
perfLogger.log('before puppeteerPlayback');
|
|
97
|
-
const puppeteerPlayback = require('./puppeteerHybridStepPlayback').execute;
|
|
98
|
-
try {
|
|
99
|
-
return await puppeteerPlayback(player, hybridFunction, step, context, source, abortSignal);
|
|
100
|
-
} finally {
|
|
101
|
-
perfLogger.log('after puppeteerPlayback');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (hybridFunction.type === 'playwright') {
|
|
106
|
-
if (!player.driver.cdpUrl) {
|
|
107
|
-
return { success: false, shouldRetry: false, reason: 'running playwright code requires the remote debugging protocol to be open. Please contact Testim support.' };
|
|
108
|
-
}
|
|
109
|
-
const playwrightPlayback = require('./playwrightHybridStepPlayback').execute;
|
|
110
|
-
return await playwrightPlayback(player, hybridFunction, step, context, source, abortSignal);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (hybridFunction.type === 'tdk' || !hybridFunction.type) {
|
|
114
|
-
const tdkPlayback = require('./tdkHybridStepPlayback').execute;
|
|
115
|
-
perfLogger.log('before tdkPlayback');
|
|
116
|
-
try {
|
|
117
|
-
return await tdkPlayback(player, hybridFunction, context, loginData, frameManager, step, source, abortSignal);
|
|
118
|
-
} finally {
|
|
119
|
-
perfLogger.log('after tdkPlayback');
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return { success: false, shouldRetry: false, reason: `unknown hybrid format ${hybridFunction.type}` };
|
|
124
|
-
} catch (err) {
|
|
125
|
-
logger.info('error running hybrid step', { err });
|
|
126
|
-
return undefined;
|
|
127
|
-
} finally {
|
|
128
|
-
runningStepsAbortControllersRegistry.delete(context.stepResultId);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
module.exports.abort = function abort(stepResultId) {
|
|
133
|
-
const abortController = runningStepsAbortControllersRegistry.get(stepResultId);
|
|
134
|
-
|
|
135
|
-
if (abortController) {
|
|
136
|
-
abortController.abort();
|
|
137
|
-
} else {
|
|
138
|
-
throw new Error('No such stepResultId');
|
|
139
|
-
}
|
|
140
|
-
};
|