@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,47 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const express = require('express');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
standaloneBrowserRoutes,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {{
|
|
13
|
-
webdriverApi: import("../../../player/WebdriverioWebDriverApi")
|
|
14
|
-
}} [testimStandaloneBrowser]
|
|
15
|
-
*/
|
|
16
|
-
function standaloneBrowserRoutes(testimStandaloneBrowser) {
|
|
17
|
-
const router = express.Router();
|
|
18
|
-
|
|
19
|
-
router.get('/cdp-url', (req, res) => {
|
|
20
|
-
if (!testimStandaloneBrowser) {
|
|
21
|
-
res.status(503).send({
|
|
22
|
-
error: 'Testim standalone browser is not running',
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
res.status(200).send({
|
|
29
|
-
url: testimStandaloneBrowser.webdriverApi.cdpUrl,
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
router.get('/status', (req, res) => {
|
|
34
|
-
if (!testimStandaloneBrowser) {
|
|
35
|
-
res.status(503).send({
|
|
36
|
-
ok: false,
|
|
37
|
-
});
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
res.status(200).send({
|
|
42
|
-
ok: true,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return router;
|
|
47
|
-
}
|
package/agent/server.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { ArgError } = require('../errors');
|
|
4
|
-
const testimCustomToken = require('../commons/testimCustomToken');
|
|
5
|
-
const lazyRequire = require('../commons/lazyRequire');
|
|
6
|
-
const { prepareChromeDriver } = require('../commons/prepareRunnerAndTestimStartUtils');
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
init,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {*} param0
|
|
15
|
-
* @param {{
|
|
16
|
-
webdriverApi: import("../player/WebdriverioWebDriverApi")
|
|
17
|
-
}} [testimStandaloneBrowser]
|
|
18
|
-
*/
|
|
19
|
-
async function init({
|
|
20
|
-
agentPort,
|
|
21
|
-
agentBind,
|
|
22
|
-
project,
|
|
23
|
-
token,
|
|
24
|
-
installPlaygroundPlaywrightDeps,
|
|
25
|
-
installPlaygroundPuppeteerDeps,
|
|
26
|
-
installPlaygroundSeleniumDeps,
|
|
27
|
-
}, testimStandaloneBrowser) {
|
|
28
|
-
await installExternalPackages({
|
|
29
|
-
installPlaygroundPlaywrightDeps,
|
|
30
|
-
installPlaygroundPuppeteerDeps,
|
|
31
|
-
installPlaygroundSeleniumDeps,
|
|
32
|
-
project,
|
|
33
|
-
});
|
|
34
|
-
await initServer({
|
|
35
|
-
agentPort,
|
|
36
|
-
agentBind,
|
|
37
|
-
project,
|
|
38
|
-
token,
|
|
39
|
-
}, testimStandaloneBrowser);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @param {*} param0
|
|
45
|
-
* @param {{
|
|
46
|
-
webdriverApi: import("../player/WebdriverioWebDriverApi")
|
|
47
|
-
}} [testimStandaloneBrowser]
|
|
48
|
-
*/
|
|
49
|
-
function initServer({
|
|
50
|
-
agentPort, agentBind, project, token,
|
|
51
|
-
}, testimStandaloneBrowser) {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
/**
|
|
54
|
-
* Init testim auth for making services request.
|
|
55
|
-
*/
|
|
56
|
-
let initFn = () => { };
|
|
57
|
-
if (project) {
|
|
58
|
-
testimCustomToken.init(project, token);
|
|
59
|
-
initFn = (app) => {
|
|
60
|
-
app.use((req, res, next) => {
|
|
61
|
-
req.project = project;
|
|
62
|
-
next();
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const app = require('./routers')(initFn, testimStandaloneBrowser);
|
|
68
|
-
const http = require('http');
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Create HTTP server.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
const server = http.createServer(app);
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Listen on provided port, on all network interfaces.
|
|
78
|
-
*/
|
|
79
|
-
server.listen(agentPort, agentBind);
|
|
80
|
-
|
|
81
|
-
// logger.info('Node Version', process.version);
|
|
82
|
-
|
|
83
|
-
server.on('error', onError);
|
|
84
|
-
server.on('listening', onListening);
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Event listener for HTTP server "error" event.
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
function onError(error) {
|
|
91
|
-
if (error.syscall !== 'listen') {
|
|
92
|
-
return reject(error);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// handle specific listen errors with friendly messages
|
|
96
|
-
switch (error.code) {
|
|
97
|
-
case 'EACCES':
|
|
98
|
-
case 'EPERM':
|
|
99
|
-
return reject(new ArgError(`Port ${agentPort} requires elevated privileges`));
|
|
100
|
-
case 'EADDRINUSE':
|
|
101
|
-
return reject(new ArgError(`Port ${agentPort} is already in use, is another Testim instance running?`));
|
|
102
|
-
default:
|
|
103
|
-
return reject(error);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Event listener for HTTP server "listening" event.
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
function onListening() {
|
|
112
|
-
const { port } = server.address();
|
|
113
|
-
// eslint-disable-next-line no-console
|
|
114
|
-
console.log(`Running on port: ${port}`);
|
|
115
|
-
showStartStopOptions();
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function installExternalPackages({ installPlaygroundPlaywrightDeps, installPlaygroundPuppeteerDeps, installPlaygroundSeleniumDeps, project }) {
|
|
121
|
-
const all = [];
|
|
122
|
-
if (installPlaygroundPlaywrightDeps) {
|
|
123
|
-
all.push(lazyRequire('playwright'));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (installPlaygroundPuppeteerDeps) {
|
|
127
|
-
all.push(lazyRequire('puppeteer'));
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (installPlaygroundSeleniumDeps) {
|
|
131
|
-
all.push(lazyRequire('selenium-webdriver'), prepareChromeDriver({ projectId: project }));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return Promise.all(all);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
async function showStartStopOptions() {
|
|
139
|
-
const prompts = require('prompts');
|
|
140
|
-
const isMac = process.platform === 'darwin';
|
|
141
|
-
const sigint = 'Ctrl + C';
|
|
142
|
-
await prompts({
|
|
143
|
-
type: 'text',
|
|
144
|
-
message: `Type the word "stop" or Press ${sigint}.`,
|
|
145
|
-
validate: x => x.toUpperCase().trim() === 'STOP',
|
|
146
|
-
});
|
|
147
|
-
// eslint-disable-next-line no-console
|
|
148
|
-
console.log('Exiting Testim CLI');
|
|
149
|
-
process.exit(0);
|
|
150
|
-
}
|
package/cdpTestRunner.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const WebSocket = require('ws');
|
|
2
|
-
const { promiseFromCallback } = require('./utils');
|
|
3
|
-
|
|
4
|
-
class CDPTestRunner {
|
|
5
|
-
constructor() {
|
|
6
|
-
this._cdpUrl = null;
|
|
7
|
-
this._cdpCallbacks = new Map();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async initSession(cdpUrl, timeout = 500) {
|
|
11
|
-
await this.stopSession();
|
|
12
|
-
this._cdpUrl = cdpUrl;
|
|
13
|
-
await this.initCDPWebsocket(timeout);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async initCDPWebsocket(timeout = 500) {
|
|
17
|
-
if (this._cdpWs) {
|
|
18
|
-
return this._cdpWs;
|
|
19
|
-
}
|
|
20
|
-
const websocket = new WebSocket(this._cdpUrl, { timeout });
|
|
21
|
-
|
|
22
|
-
const openPromise = promiseFromCallback((cb) => {
|
|
23
|
-
websocket.once('open', cb);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const errorPromise = promiseFromCallback((cb) => {
|
|
27
|
-
websocket.once('error', cb);
|
|
28
|
-
}).catch(() => {
|
|
29
|
-
websocket.close();
|
|
30
|
-
websocket.removeAllListeners();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
websocket.on('message', (message) => this.onCDPMessage(message));
|
|
34
|
-
|
|
35
|
-
this._cdpWs = Promise.race([openPromise, errorPromise]).then(() => websocket);
|
|
36
|
-
return this._cdpWs;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
onCDPMessage(message) {
|
|
40
|
-
const object = JSON.parse(message);
|
|
41
|
-
const callback = this._cdpCallbacks.get(object.id);
|
|
42
|
-
if (!callback) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
this._cdpCallbacks.delete(object.id);
|
|
46
|
-
if (object.error) {
|
|
47
|
-
callback.reject(new Error(object.error));
|
|
48
|
-
} else if (object.result.exceptionDetails?.exception) {
|
|
49
|
-
callback.reject(new Error(object.result.exceptionDetails.exception.description));
|
|
50
|
-
} else {
|
|
51
|
-
callback.resolve(object.result);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async stopSession() {
|
|
56
|
-
const websocket = this._cdpWs;
|
|
57
|
-
this._cdpUrl = null;
|
|
58
|
-
this._cdpWs = null;
|
|
59
|
-
this._cdpCallbacks.clear();
|
|
60
|
-
if (websocket) {
|
|
61
|
-
try {
|
|
62
|
-
return await websocket.close();
|
|
63
|
-
} catch (e) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async cdpCommand(method, params, sessionId) {
|
|
71
|
-
const websocket = await this.initCDPWebsocket();
|
|
72
|
-
this._lastWsId = this._lastWsId || 0;
|
|
73
|
-
const id = this._lastWsId++;
|
|
74
|
-
const result = new Promise((resolve, reject) => {
|
|
75
|
-
this._cdpCallbacks.set(id, { resolve, reject });
|
|
76
|
-
});
|
|
77
|
-
const msg = { method, params, id };
|
|
78
|
-
if (sessionId) {
|
|
79
|
-
Object.assign(msg, { sessionId });
|
|
80
|
-
}
|
|
81
|
-
websocket.send(JSON.stringify(msg));
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = CDPTestRunner;
|
package/chromiumInstaller.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const os = require('os');
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const { ArgError } = require('./errors');
|
|
5
|
-
const { downloadAndSave, unzipFile, TESTIM_BROWSER_DIR } = require('./utils');
|
|
6
|
-
const ora = require('ora');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const CHROMIUM_VERSION = '1000968'; // '973306' = 101.0.4899.0 '1000968' = 103.0.5046.0;
|
|
10
|
-
const DOWNLOAD_CHROME_FOLDER = path.join(TESTIM_BROWSER_DIR, `chrome-${CHROMIUM_VERSION}`);
|
|
11
|
-
|
|
12
|
-
function getCurrentPlatform() {
|
|
13
|
-
const osType = os.type().toLowerCase();
|
|
14
|
-
if (osType === 'darwin') {
|
|
15
|
-
return os.arch() === 'arm' ? 'mac_arm' : 'mac';
|
|
16
|
-
}
|
|
17
|
-
if (osType === 'windows_nt') {
|
|
18
|
-
return os.arch() === 'x64' ? 'win64' : 'win32';
|
|
19
|
-
}
|
|
20
|
-
return 'linux';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function downloadAndInstallChromium() {
|
|
24
|
-
/** Inspired by puppeteer's implementation https://github.com/puppeteer/puppeteer/blob/main/src/node/BrowserFetcher.ts#L45 */
|
|
25
|
-
const platform = getCurrentPlatform();
|
|
26
|
-
|
|
27
|
-
// example download url: https://storage.googleapis.com/chromium-browser-snapshots/Mac/1000968/chrome-mac.zip
|
|
28
|
-
const storageBaseUrl = 'https://storage.googleapis.com/chromium-browser-snapshots';
|
|
29
|
-
const platformFolder = {
|
|
30
|
-
linux: 'Linux_x64',
|
|
31
|
-
mac: 'Mac',
|
|
32
|
-
mac_arm: 'Mac_Arm', // eslint-disable-line camelcase
|
|
33
|
-
win32: 'Win',
|
|
34
|
-
win64: 'Win_x64',
|
|
35
|
-
};
|
|
36
|
-
if (!(platform in platformFolder)) {
|
|
37
|
-
throw new ArgError(`Unsupported platform: ${platform}`);
|
|
38
|
-
}
|
|
39
|
-
// Windows archive name changed at r591479.
|
|
40
|
-
const winArchiveName = parseInt(CHROMIUM_VERSION, 10) > 591479 ? 'chrome-win' : 'chrome-win32';
|
|
41
|
-
const platformArchiveName = {
|
|
42
|
-
linux: 'chrome-linux',
|
|
43
|
-
mac: 'chrome-mac',
|
|
44
|
-
mac_arm: 'chrome-mac', // eslint-disable-line camelcase
|
|
45
|
-
win32: winArchiveName,
|
|
46
|
-
win64: winArchiveName,
|
|
47
|
-
};
|
|
48
|
-
const binaryPaths = {
|
|
49
|
-
linux: 'chrome',
|
|
50
|
-
mac: 'Chromium.app/Contents/MacOS/Chromium',
|
|
51
|
-
mac_arm: 'Chromium.app/Contents/MacOS/Chromium', // eslint-disable-line camelcase
|
|
52
|
-
win32: 'chrome.exe',
|
|
53
|
-
win64: 'chrome.exe',
|
|
54
|
-
};
|
|
55
|
-
const downloadUrl = `${storageBaseUrl}/${platformFolder[platform]}/${CHROMIUM_VERSION}/${platformArchiveName[platform]}.zip`;
|
|
56
|
-
const downloadArchivePath = path.join(DOWNLOAD_CHROME_FOLDER, platformArchiveName[platform]);
|
|
57
|
-
const downloadedZipFile = `${downloadArchivePath}.zip`;
|
|
58
|
-
const binaryPath = path.join(downloadArchivePath, binaryPaths[platform]);
|
|
59
|
-
|
|
60
|
-
if (await fs.pathExists(binaryPath)) {
|
|
61
|
-
return binaryPath;
|
|
62
|
-
}
|
|
63
|
-
if (!(await fs.pathExists(downloadedZipFile))) {
|
|
64
|
-
const downloadSpinner = ora('Downloading Chromium').start();
|
|
65
|
-
try {
|
|
66
|
-
await fs.mkdirp(DOWNLOAD_CHROME_FOLDER);
|
|
67
|
-
await downloadAndSave(downloadUrl, downloadedZipFile);
|
|
68
|
-
// todo - We can add a failover here if the download fails if we host the file too
|
|
69
|
-
} catch (e) {
|
|
70
|
-
const errorMessage = `Failed to download Chromium: ${e.message}`;
|
|
71
|
-
downloadSpinner.fail(errorMessage);
|
|
72
|
-
throw new Error(errorMessage);
|
|
73
|
-
}
|
|
74
|
-
downloadSpinner.succeed();
|
|
75
|
-
}
|
|
76
|
-
const extractSpinner = ora('Extracting Chromium').start();
|
|
77
|
-
try {
|
|
78
|
-
await unzipFile(downloadedZipFile, DOWNLOAD_CHROME_FOLDER);
|
|
79
|
-
} catch (e) {
|
|
80
|
-
const errorMessage = `Failed to extract Chromium: ${e.message}`;
|
|
81
|
-
extractSpinner.fail(errorMessage);
|
|
82
|
-
throw new Error(errorMessage);
|
|
83
|
-
}
|
|
84
|
-
extractSpinner.succeed();
|
|
85
|
-
return binaryPath;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
module.exports = {
|
|
89
|
-
CHROMIUM_VERSION,
|
|
90
|
-
downloadAndInstallChromium,
|
|
91
|
-
};
|
package/cli/isCiRun.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// copied from https://github.com/watson/ci-info/blob/master/index.js
|
|
4
|
-
module.exports.isCi = !!(
|
|
5
|
-
process.env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
|
|
6
|
-
process.env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
|
|
7
|
-
process.env.BUILD_NUMBER || // Jenkins, TeamCity
|
|
8
|
-
process.env.RUN_ID || // TaskCluster, dsari
|
|
9
|
-
false
|
|
10
|
-
);
|
package/cli/onExit.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const constants = require('../commons/constants');
|
|
4
|
-
const { requireWithFallback } = require('../commons/requireWithFallback');
|
|
5
|
-
const { isCi } = require('./isCiRun');
|
|
6
|
-
const { writeStackTrace } = require('./writeStackTrace');
|
|
7
|
-
const logger = require('../commons/logger').getLogger('process-handler');
|
|
8
|
-
|
|
9
|
-
let exitCodeIgnoreFailingTests = false;
|
|
10
|
-
|
|
11
|
-
function getExitCode(result) {
|
|
12
|
-
if (result instanceof Error) {
|
|
13
|
-
return 1;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (exitCodeIgnoreFailingTests) {
|
|
17
|
-
return 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
result = result || {};
|
|
21
|
-
const hasFailedTests = Object.values(result).some(
|
|
22
|
-
({ runnerStatus, success, testStatus, status }) => {
|
|
23
|
-
if (
|
|
24
|
-
[runnerStatus, status].includes(constants.runnerTestStatus.SKIPPED) ||
|
|
25
|
-
([runnerStatus, status].includes(constants.runnerTestStatus.FAILED) &&
|
|
26
|
-
testStatus === constants.testStatus.EVALUATING)
|
|
27
|
-
) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return success !== true;
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return hasFailedTests ? 1 : 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function closeChromeDriverIfRunning() {
|
|
38
|
-
try {
|
|
39
|
-
const chromedriver = requireWithFallback('chromedriver');
|
|
40
|
-
chromedriver.stop();
|
|
41
|
-
// eslint-disable-next-line no-empty
|
|
42
|
-
} catch (err) { }
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports.ignoreFailingTestsInExitCode = function () {
|
|
46
|
-
exitCodeIgnoreFailingTests = true;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
module.exports.onExit = async function onExit(exitValue) {
|
|
51
|
-
if (exitValue?.stack) {
|
|
52
|
-
if (!isCi) {
|
|
53
|
-
writeStackTrace(exitValue);
|
|
54
|
-
} else {
|
|
55
|
-
// eslint-disable-next-line no-console
|
|
56
|
-
console.error(exitValue, exitValue.stack);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
closeChromeDriverIfRunning();
|
|
61
|
-
|
|
62
|
-
await logger.waitForFlush();
|
|
63
|
-
|
|
64
|
-
process.exit(getExitCode(exitValue));
|
|
65
|
-
};
|
package/cli/writeStackTrace.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
const os = require('os');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const fse = require('fs-extra');
|
|
7
|
-
|
|
8
|
-
module.exports.writeStackTrace = function writeStackTrace(err) {
|
|
9
|
-
if (err?.message?.includes('SIGINT')) {
|
|
10
|
-
return; // no need to generate a log file for a sigint.
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
const homedir = os.homedir();
|
|
14
|
-
|
|
15
|
-
fse.ensureDirSync(path.resolve(homedir, '.testim_logs'));
|
|
16
|
-
const logFileName = path.resolve(homedir, '.testim_logs', `${new Date().toISOString().replace(/:|\./g, '_')}.log`);
|
|
17
|
-
console.log('Oops :( The test runner has encountered an unexpected error. A complete log of this run can be found in:');
|
|
18
|
-
console.log(`\t${logFileName}`);
|
|
19
|
-
|
|
20
|
-
if (err?.message?.includes('Unable to compile TypeScript') && err.stack.includes('runner/src') && process.argv.some(x => x.includes('player-require-path'))) {
|
|
21
|
-
console.log(chalk.red('Looks like you got a TypeScript compile error champ - but it\'s not a very good one because we use TypeScript in transpile-only mode'));
|
|
22
|
-
console.log(chalk.red('change require(\'ts-node/register/transpile-only\'); to require(\'ts-node/register\'); for better errors'));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
fse.writeFileSync(logFileName, `${err}\n${err.stack}\n\n${JSON.stringify(err, Object.getOwnPropertyNames(err), 2)}`);
|
|
26
|
-
} catch { /* noop */ }
|
|
27
|
-
};
|