browserstack-cypress-cli 1.27.0 → 1.28.1
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/bin/accessibility-automation/helper.js +3 -1
- package/bin/commands/info.js +5 -0
- package/bin/commands/runs.js +37 -6
- package/bin/commands/stop.js +5 -3
- package/bin/helpers/atsHelper.js +118 -0
- package/bin/helpers/build.js +4 -0
- package/bin/helpers/checkUploaded.js +4 -0
- package/bin/helpers/config.js +6 -2
- package/bin/helpers/config.json +3 -1
- package/bin/helpers/constants.js +3 -0
- package/bin/helpers/helper.js +13 -3
- package/bin/helpers/sync/syncSpecsLogs.js +8 -2
- package/bin/helpers/utils.js +20 -2
- package/bin/testObservability/helper/constants.js +4 -0
- package/bin/testObservability/helper/helper.js +88 -27
- package/bin/testObservability/reporter/index.js +3 -3
- package/package.json +1 -1
|
@@ -191,7 +191,9 @@ const getAccessibilityCypressCommandEventListener = () => {
|
|
|
191
191
|
const setAccessibilityEventListeners = () => {
|
|
192
192
|
try {
|
|
193
193
|
const cypressCommandEventListener = getAccessibilityCypressCommandEventListener();
|
|
194
|
-
|
|
194
|
+
|
|
195
|
+
// Searching form command.js recursively
|
|
196
|
+
glob(process.cwd() + '/**/cypress/support/*.js', {}, (err, files) => {
|
|
195
197
|
if(err) return logger.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files');
|
|
196
198
|
files.forEach(file => {
|
|
197
199
|
try {
|
package/bin/commands/info.js
CHANGED
|
@@ -38,6 +38,11 @@ module.exports = function info(args, rawArgs) {
|
|
|
38
38
|
'User-Agent': utils.getUserAgent(),
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
|
+
|
|
42
|
+
if (Constants.turboScaleObj.enabled) {
|
|
43
|
+
options.url = `${config.turboScaleBuildsUrl}/${buildId}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
request.get(options, function (err, resp, body) {
|
|
42
47
|
let message = null;
|
|
43
48
|
let messageType = null;
|
package/bin/commands/runs.js
CHANGED
|
@@ -36,6 +36,7 @@ const {
|
|
|
36
36
|
checkAccessibilityPlatform,
|
|
37
37
|
supportFileCleanup
|
|
38
38
|
} = require('../accessibility-automation/helper');
|
|
39
|
+
const { isTurboScaleSession, getTurboScaleGridDetails, patchCypressConfigFileContent, atsFileCleanup } = require('../helpers/atsHelper');
|
|
39
40
|
|
|
40
41
|
module.exports = function run(args, rawArgs) {
|
|
41
42
|
|
|
@@ -66,6 +67,8 @@ module.exports = function run(args, rawArgs) {
|
|
|
66
67
|
const [isTestObservabilitySession, isBrowserstackInfra] = setTestObservabilityFlags(bsConfig);
|
|
67
68
|
const checkAccessibility = checkAccessibilityPlatform(bsConfig);
|
|
68
69
|
const isAccessibilitySession = bsConfig.run_settings.accessibility || checkAccessibility;
|
|
70
|
+
const turboScaleSession = isTurboScaleSession(bsConfig);
|
|
71
|
+
Constants.turboScaleObj.enabled = turboScaleSession;
|
|
69
72
|
|
|
70
73
|
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
|
|
71
74
|
|
|
@@ -77,7 +80,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
77
80
|
// accept the access key from command line or env variable if provided
|
|
78
81
|
utils.setAccessKey(bsConfig, args);
|
|
79
82
|
|
|
80
|
-
let buildReportData = !isBrowserstackInfra ? null : await getInitialDetails(bsConfig, args, rawArgs);
|
|
83
|
+
let buildReportData = (turboScaleSession || !isBrowserstackInfra) ? null : await getInitialDetails(bsConfig, args, rawArgs);
|
|
81
84
|
|
|
82
85
|
// accept the build name from command line if provided
|
|
83
86
|
utils.setBuildName(bsConfig, args);
|
|
@@ -147,6 +150,29 @@ module.exports = function run(args, rawArgs) {
|
|
|
147
150
|
if (isAccessibilitySession && isBrowserstackInfra) {
|
|
148
151
|
await createAccessibilityTestRun(bsConfig);
|
|
149
152
|
}
|
|
153
|
+
|
|
154
|
+
if (turboScaleSession) {
|
|
155
|
+
// Local is only required in case user is running on trial grid and wants to access private website.
|
|
156
|
+
// Even then, it will be spawned separately via browserstack-cli ats connect-grid command and not via browserstack-cypress-cli
|
|
157
|
+
// Hence whenever running on ATS, need to make local as false
|
|
158
|
+
bsConfig.connection_settings.local = false;
|
|
159
|
+
|
|
160
|
+
const gridDetails = await getTurboScaleGridDetails(bsConfig, args, rawArgs);
|
|
161
|
+
|
|
162
|
+
if (gridDetails && Object.keys(gridDetails).length > 0) {
|
|
163
|
+
Constants.turboScaleObj.gridDetails = gridDetails;
|
|
164
|
+
Constants.turboScaleObj.gridUrl = gridDetails.cypressUrl;
|
|
165
|
+
Constants.turboScaleObj.uploadUrl = gridDetails.cypressUrl + '/upload';
|
|
166
|
+
Constants.turboScaleObj.buildUrl = gridDetails.cypressUrl + '/build';
|
|
167
|
+
|
|
168
|
+
logger.debug(`Automate TurboScale Grid URL set to ${gridDetails.url}`);
|
|
169
|
+
|
|
170
|
+
patchCypressConfigFileContent(bsConfig);
|
|
171
|
+
} else {
|
|
172
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
150
176
|
}
|
|
151
177
|
|
|
152
178
|
const { packagesInstalled } = !isBrowserstackInfra ? false : await packageInstaller.packageSetupAndInstaller(bsConfig, config.packageDirName, {markBlockStart, markBlockEnd});
|
|
@@ -186,7 +212,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
186
212
|
|
|
187
213
|
//get the number of spec files
|
|
188
214
|
markBlockStart('getNumberOfSpecFiles');
|
|
189
|
-
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressConfigFile);
|
|
215
|
+
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressConfigFile, turboScaleSession);
|
|
190
216
|
markBlockEnd('getNumberOfSpecFiles');
|
|
191
217
|
|
|
192
218
|
bsConfig['run_settings']['video_config'] = utils.getVideoConfig(cypressConfigFile, bsConfig);
|
|
@@ -251,6 +277,11 @@ module.exports = function run(args, rawArgs) {
|
|
|
251
277
|
if (process.env.BROWSERSTACK_TEST_ACCESSIBILITY === 'true') {
|
|
252
278
|
supportFileCleanup();
|
|
253
279
|
}
|
|
280
|
+
|
|
281
|
+
if (turboScaleSession) {
|
|
282
|
+
atsFileCleanup(bsConfig);
|
|
283
|
+
}
|
|
284
|
+
|
|
254
285
|
// Set config args for enforce_settings
|
|
255
286
|
if ( !utils.isUndefinedOrFalse(bsConfig.run_settings.enforce_settings) ) {
|
|
256
287
|
markBlockStart('setEnforceSettingsConfig');
|
|
@@ -310,13 +341,13 @@ module.exports = function run(args, rawArgs) {
|
|
|
310
341
|
logger.debug("Completed polling of build status");
|
|
311
342
|
|
|
312
343
|
// stop the Local instance
|
|
313
|
-
await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
|
|
344
|
+
if (!turboScaleSession) await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
|
|
314
345
|
|
|
315
346
|
// waiting for 5 secs for upload to complete (as a safety measure)
|
|
316
347
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
317
348
|
|
|
318
349
|
// download build artifacts
|
|
319
|
-
if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
|
|
350
|
+
if (exitCode != Constants.BUILD_FAILED_EXIT_CODE && !turboScaleSession) {
|
|
320
351
|
if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
|
|
321
352
|
logger.debug("Downloading build artifacts");
|
|
322
353
|
await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData);
|
|
@@ -328,7 +359,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
328
359
|
markBlockEnd('postBuild');
|
|
329
360
|
utils.handleSyncExit(exitCode, data.dashboard_url);
|
|
330
361
|
});
|
|
331
|
-
} else {
|
|
362
|
+
} else if(!turboScaleSession){
|
|
332
363
|
let stacktraceUrl = getStackTraceUrl();
|
|
333
364
|
downloadBuildStacktrace(stacktraceUrl).then((message) => {
|
|
334
365
|
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
@@ -344,7 +375,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
344
375
|
});
|
|
345
376
|
}
|
|
346
377
|
});
|
|
347
|
-
} else if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
|
|
378
|
+
} else if (utils.nonEmptyArray(bsConfig.run_settings.downloads && !turboScaleSession)) {
|
|
348
379
|
logger.info(Constants.userMessages.ASYNC_DOWNLOADS.replace('<build-id>', data.build_id));
|
|
349
380
|
}
|
|
350
381
|
|
package/bin/commands/stop.js
CHANGED
|
@@ -19,17 +19,19 @@ module.exports = function stop(args, rawArgs) {
|
|
|
19
19
|
// accept the access key from command line if provided
|
|
20
20
|
utils.setAccessKey(bsConfig, args);
|
|
21
21
|
|
|
22
|
-
let buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
|
|
23
|
-
|
|
24
22
|
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
|
|
25
23
|
|
|
26
24
|
// set cypress config filename
|
|
27
25
|
utils.setCypressConfigFilename(bsConfig, args);
|
|
28
26
|
|
|
29
27
|
let buildId = args._[1];
|
|
28
|
+
let buildReportData = null;
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
if (!Constants.turboScaleObj.enabled) {
|
|
31
|
+
buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
|
|
32
|
+
}
|
|
32
33
|
|
|
34
|
+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs, buildReportData);
|
|
33
35
|
}).catch(function (err) {
|
|
34
36
|
logger.error(err);
|
|
35
37
|
utils.setUsageReportingFlag(null, args.disableUsageReporting);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
|
|
4
|
+
const request = require('request'),
|
|
5
|
+
logger = require('./logger').winstonLogger,
|
|
6
|
+
utils = require('./utils'),
|
|
7
|
+
config = require('./config');
|
|
8
|
+
Constants = require('./constants');
|
|
9
|
+
|
|
10
|
+
exports.isTurboScaleSession = (bsConfig) => {
|
|
11
|
+
// env var will override config
|
|
12
|
+
if (process.env.BROWSERSTACK_TURBOSCALE && process.env.BROWSERSTACK_TURBOSCALE === 'true') {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (bsConfig.run_settings && bsConfig.run_settings.turboScale) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.getTurboScaleOptions = (bsConfig) => {
|
|
24
|
+
if (bsConfig.run_settings && bsConfig.run_settings.turboScaleOptions) {
|
|
25
|
+
return bsConfig.run_settings.turboScaleOptions;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.getTurboScaleGridName = (bsConfig) => {
|
|
32
|
+
// env var will override config
|
|
33
|
+
if (process.env.BROWSERSTACK_TURBOSCALE_GRID_NAME) {
|
|
34
|
+
return process.env.BROWSERSTACK_TURBOSCALE_GRID_NAME;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (bsConfig.run_settings && bsConfig.run_settings.turboScaleOptions && bsConfig.run_settings.turboScaleOptions.gridName) {
|
|
38
|
+
return bsConfig.run_settings.turboScaleOptions.gridName;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return 'NO_GRID_NAME_PASSED';
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.getTurboScaleGridDetails = async (bsConfig, args, rawArgs) => {
|
|
45
|
+
try {
|
|
46
|
+
const gridName = this.getTurboScaleGridName(bsConfig);
|
|
47
|
+
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
let options = {
|
|
50
|
+
url: `${config.turboScaleAPIUrl}/grids/${gridName}`,
|
|
51
|
+
auth: {
|
|
52
|
+
username: bsConfig.auth.username,
|
|
53
|
+
password: bsConfig.auth.access_key,
|
|
54
|
+
},
|
|
55
|
+
headers: {
|
|
56
|
+
'User-Agent': utils.getUserAgent(),
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
let responseData = {};
|
|
60
|
+
request.get(options, function (err, resp, data) {
|
|
61
|
+
if(err) {
|
|
62
|
+
logger.warn(utils.formatRequest(err, resp, data));
|
|
63
|
+
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'get_ats_details_failed', null, rawArgs);
|
|
64
|
+
resolve({});
|
|
65
|
+
} else {
|
|
66
|
+
try {
|
|
67
|
+
responseData = JSON.parse(data);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
responseData = {};
|
|
70
|
+
}
|
|
71
|
+
if(resp.statusCode != 200) {
|
|
72
|
+
logger.warn(`Warn: Get Automate TurboScale Details Request failed with status code ${resp.statusCode}`);
|
|
73
|
+
utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'get_ats_details_failed', null, rawArgs);
|
|
74
|
+
resolve({});
|
|
75
|
+
}
|
|
76
|
+
resolve(responseData);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
} catch (err) {
|
|
81
|
+
logger.error(`Failed to find TurboScale Grid: ${err}: ${err.stack}`);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.patchCypressConfigFileContent = (bsConfig) => {
|
|
86
|
+
try {
|
|
87
|
+
let cypressConfigFileData = fs.readFileSync(path.resolve(bsConfig.run_settings.cypress_config_file)).toString();
|
|
88
|
+
const patchedConfigFileData = cypressConfigFileData + '\n\n' + `
|
|
89
|
+
let originalFunction = module.exports.e2e.setupNodeEvents;
|
|
90
|
+
|
|
91
|
+
module.exports.e2e.setupNodeEvents = (on, config) => {
|
|
92
|
+
const bstackOn = require("./cypressPatch.js")(on);
|
|
93
|
+
if (originalFunction !== null && originalFunction !== undefined) {
|
|
94
|
+
originalFunction(bstackOn, config);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
`
|
|
98
|
+
|
|
99
|
+
let confPath = bsConfig.run_settings.cypress_config_file;
|
|
100
|
+
let patchedConfPathList = confPath.split(path.sep);
|
|
101
|
+
patchedConfPathList[patchedConfPathList.length - 1] = 'patched_ats_config_file.js'
|
|
102
|
+
const patchedConfPath = patchedConfPathList.join(path.sep);
|
|
103
|
+
|
|
104
|
+
bsConfig.run_settings.patched_cypress_config_file = patchedConfPath;
|
|
105
|
+
|
|
106
|
+
fs.writeFileSync(path.resolve(bsConfig.run_settings.patched_cypress_config_file), patchedConfigFileData);
|
|
107
|
+
} catch(e) {
|
|
108
|
+
logger.error(`Encountered an error when trying to patch ATS Cypress Config File ${e}`);
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
exports.atsFileCleanup = (bsConfig) => {
|
|
114
|
+
const filePath = path.resolve(bsConfig.run_settings.patched_cypress_config_file);
|
|
115
|
+
if(fs.existsSync(filePath)){
|
|
116
|
+
fs.unlinkSync(filePath);
|
|
117
|
+
}
|
|
118
|
+
}
|
package/bin/helpers/build.js
CHANGED
|
@@ -23,6 +23,10 @@ const createBuild = (bsConfig, zip) => {
|
|
|
23
23
|
body: data
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
if (Constants.turboScaleObj.enabled) {
|
|
27
|
+
options.url = Constants.turboScaleObj.buildUrl;
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
request.post(options, function (err, resp, body) {
|
|
27
31
|
if (err) {
|
|
28
32
|
logger.error(utils.formatRequest(err, resp, body));
|
|
@@ -121,6 +121,10 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
121
121
|
body: JSON.stringify(data)
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
+
if (Constants.turboScaleObj.enabled) {
|
|
125
|
+
options.url = config.turboScaleMd5Sum;
|
|
126
|
+
}
|
|
127
|
+
|
|
124
128
|
instrumentBlocks.markBlockStart("checkAlreadyUploaded.railsCheck");
|
|
125
129
|
request.post(options, function (err, resp, body) {
|
|
126
130
|
if (err) {
|
package/bin/helpers/config.js
CHANGED
|
@@ -24,7 +24,11 @@ config.packageFileName = "bstackPackages.tar.gz";
|
|
|
24
24
|
config.packageDirName = "tmpBstackPackages";
|
|
25
25
|
config.retries = 5;
|
|
26
26
|
config.networkErrorExitCode = 2;
|
|
27
|
-
config.compiledConfigJsDirName = 'tmpBstackCompiledJs'
|
|
28
|
-
config.configJsonFileName = 'tmpCypressConfig.json'
|
|
27
|
+
config.compiledConfigJsDirName = 'tmpBstackCompiledJs';
|
|
28
|
+
config.configJsonFileName = 'tmpCypressConfig.json';
|
|
29
|
+
|
|
30
|
+
// turboScale
|
|
31
|
+
config.turboScaleMd5Sum = `${config.turboScaleUrl}/md5sumcheck`;
|
|
32
|
+
config.turboScaleBuildsUrl = `${config.turboScaleUrl}/builds`;
|
|
29
33
|
|
|
30
34
|
module.exports = config;
|
package/bin/helpers/config.json
CHANGED
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
"rails_host": "https://api.browserstack.com",
|
|
4
4
|
"dashboardUrl": "https://automate.browserstack.com/dashboard/v2/builds/",
|
|
5
5
|
"usageReportingUrl": "https://eds.browserstack.com:443/send_event_cy_internal",
|
|
6
|
-
"localTestingListUrl": "https://www.browserstack.com/local/v1/list"
|
|
6
|
+
"localTestingListUrl": "https://www.browserstack.com/local/v1/list",
|
|
7
|
+
"turboScaleUrl": "https://grid.browserstack.com/packages/cypress",
|
|
8
|
+
"turboScaleAPIUrl": "https://api.browserstack.com/automate-turboscale/v1"
|
|
7
9
|
}
|
package/bin/helpers/constants.js
CHANGED
|
@@ -441,6 +441,8 @@ const CYPRESS_CONFIG_FILE_NAMES = Object.keys(CYPRESS_CONFIG_FILE_MAPPING);
|
|
|
441
441
|
|
|
442
442
|
const CYPRESS_V10_AND_ABOVE_CONFIG_FILE_EXTENSIONS = ['js', 'ts', 'cjs', 'mjs']
|
|
443
443
|
|
|
444
|
+
const turboScaleObj = {};
|
|
445
|
+
|
|
444
446
|
module.exports = Object.freeze({
|
|
445
447
|
syncCLI,
|
|
446
448
|
userMessages,
|
|
@@ -453,6 +455,7 @@ module.exports = Object.freeze({
|
|
|
453
455
|
hashingOptions,
|
|
454
456
|
packageInstallerOptions,
|
|
455
457
|
specFileTypes,
|
|
458
|
+
turboScaleObj,
|
|
456
459
|
DEFAULT_CYPRESS_SPEC_PATH,
|
|
457
460
|
DEFAULT_CYPRESS_10_SPEC_PATH,
|
|
458
461
|
SPEC_TOTAL_CHAR_LIMIT,
|
package/bin/helpers/helper.js
CHANGED
|
@@ -267,16 +267,26 @@ exports.getCiInfo = () => {
|
|
|
267
267
|
return null;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
exports.getBuildDetails = (bsConfig) => {
|
|
270
|
+
exports.getBuildDetails = (bsConfig, isO11y = false) => {
|
|
271
|
+
const isTestObservabilityOptionsPresent = isO11y && !utils.isUndefined(bsConfig["testObservabilityOptions"]);
|
|
272
|
+
|
|
271
273
|
let buildName = '',
|
|
272
274
|
projectName = '',
|
|
273
275
|
buildDescription = '',
|
|
274
276
|
buildTags = [];
|
|
275
|
-
|
|
277
|
+
|
|
276
278
|
/* Pick from environment variables */
|
|
277
279
|
buildName = process.env.BROWSERSTACK_BUILD_NAME || buildName;
|
|
278
280
|
projectName = process.env.BROWSERSTACK_PROJECT_NAME || projectName;
|
|
279
|
-
|
|
281
|
+
|
|
282
|
+
/* Pick from testObservabilityOptions */
|
|
283
|
+
if(isTestObservabilityOptionsPresent) {
|
|
284
|
+
buildName = buildName || bsConfig["testObservabilityOptions"]["buildName"];
|
|
285
|
+
projectName = projectName || bsConfig["testObservabilityOptions"]["projectName"];
|
|
286
|
+
if(!utils.isUndefined(bsConfig["testObservabilityOptions"]["buildTag"])) buildTags = [...buildTags, ...bsConfig["testObservabilityOptions"]["buildTag"]];
|
|
287
|
+
buildDescription = buildDescription || bsConfig["testObservabilityOptions"]["buildDescription"];
|
|
288
|
+
}
|
|
289
|
+
|
|
280
290
|
/* Pick from run settings */
|
|
281
291
|
buildName = buildName || bsConfig["run_settings"]["build_name"];
|
|
282
292
|
projectName = projectName || bsConfig["run_settings"]["project_name"];
|
|
@@ -24,8 +24,8 @@ let terminalWidth = (process.stdout.columns) * 0.9;
|
|
|
24
24
|
let lineSeparator = Constants.syncCLI.DEFAULT_LINE_SEP;
|
|
25
25
|
if (!isNaN(terminalWidth)) lineSeparator = "\n" + "-".repeat(terminalWidth);
|
|
26
26
|
|
|
27
|
-
let
|
|
28
|
-
|
|
27
|
+
let getOptions = (auth, build_id) => {
|
|
28
|
+
const options = {
|
|
29
29
|
url: `${config.buildUrlV2}${build_id}`,
|
|
30
30
|
auth: {
|
|
31
31
|
user: auth.username,
|
|
@@ -37,6 +37,12 @@ let getOptions = (auth, build_id) => {
|
|
|
37
37
|
"User-Agent": utils.getUserAgent()
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
+
|
|
41
|
+
if (Constants.turboScaleObj.enabled) {
|
|
42
|
+
options.url = `${config.turboScaleBuildsUrl}/${build_id}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return options;
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
let getTableConfig = (termWidth) => {
|
package/bin/helpers/utils.js
CHANGED
|
@@ -721,6 +721,11 @@ exports.generateUploadParams = (bsConfig, filePath, md5data, fileDetails) => {
|
|
|
721
721
|
"User-Agent": exports.getUserAgent(),
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
|
+
|
|
725
|
+
if (Constants.turboScaleObj.enabled) {
|
|
726
|
+
options.url = Constants.turboScaleObj.uploadUrl;
|
|
727
|
+
}
|
|
728
|
+
|
|
724
729
|
return options
|
|
725
730
|
}
|
|
726
731
|
|
|
@@ -968,6 +973,7 @@ exports.setLocalArgs = (bsConfig, args) => {
|
|
|
968
973
|
local_args['proxyPort'] = bsConfig["connection_settings"]["proxyPort"];
|
|
969
974
|
if (bsConfig["connection_settings"]["useCaCertificate"])
|
|
970
975
|
local_args['useCaCertificate'] = bsConfig["connection_settings"]["useCaCertificate"];
|
|
976
|
+
|
|
971
977
|
local_args['daemon'] = true;
|
|
972
978
|
local_args['enable-logging-for-api'] = true
|
|
973
979
|
local_args['source'] = `cypress:${usageReporting.cli_version_and_path(bsConfig).version}`;
|
|
@@ -1070,7 +1076,7 @@ exports.getFilesToIgnore = (runSettings, excludeFiles, logging = true) => {
|
|
|
1070
1076
|
return ignoreFiles;
|
|
1071
1077
|
}
|
|
1072
1078
|
|
|
1073
|
-
exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig) => {
|
|
1079
|
+
exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig, turboScaleSession=false) => {
|
|
1074
1080
|
let defaultSpecFolder
|
|
1075
1081
|
let testFolderPath
|
|
1076
1082
|
let globCypressConfigSpecPatterns = []
|
|
@@ -1145,6 +1151,13 @@ exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig) => {
|
|
|
1145
1151
|
}
|
|
1146
1152
|
|
|
1147
1153
|
logger.debug(`${files ? files.length : 0} spec files found`);
|
|
1154
|
+
|
|
1155
|
+
if (turboScaleSession) {
|
|
1156
|
+
// remove unwanted path prefix for turboscale
|
|
1157
|
+
files = files.map((x) => { return path.join(testFolderPath, x.split(testFolderPath)[1]) })
|
|
1158
|
+
// setting specs for turboScale as we don't have patched API for turboscale so we will rely on info from CLI
|
|
1159
|
+
bsConfig.run_settings.specs = files;
|
|
1160
|
+
}
|
|
1148
1161
|
return files;
|
|
1149
1162
|
};
|
|
1150
1163
|
|
|
@@ -1327,7 +1340,7 @@ exports.setEnforceSettingsConfig = (bsConfig) => {
|
|
|
1327
1340
|
if(specConfigs && specConfigs.includes(',')) {
|
|
1328
1341
|
specConfigs = JSON.stringify(specConfigs.split(','));
|
|
1329
1342
|
}
|
|
1330
|
-
let spec_pattern_args =
|
|
1343
|
+
let spec_pattern_args = `specPattern=${specConfigs}`;
|
|
1331
1344
|
config_args = this.isUndefined(config_args) ? spec_pattern_args : config_args + ',' + spec_pattern_args;
|
|
1332
1345
|
}
|
|
1333
1346
|
if ( this.isNotUndefined(config_args) ) bsConfig["run_settings"]["config"] = config_args;
|
|
@@ -1430,6 +1443,11 @@ exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs, buildRe
|
|
|
1430
1443
|
'User-Agent': that.getUserAgent(),
|
|
1431
1444
|
},
|
|
1432
1445
|
};
|
|
1446
|
+
|
|
1447
|
+
if (Constants.turboScaleObj.enabled) {
|
|
1448
|
+
options.url = `${config.turboScaleBuildsUrl}/${buildId}/stop`;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1433
1451
|
let message = null;
|
|
1434
1452
|
let messageType = null;
|
|
1435
1453
|
let errorCode = null;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
1
3
|
exports.consoleHolder = Object.assign({},console);
|
|
2
4
|
exports.BATCH_SIZE = 1000;
|
|
3
5
|
exports.BATCH_INTERVAL = 2000;
|
|
@@ -28,3 +30,5 @@ exports.OBSERVABILITY_ENV_VARS = [
|
|
|
28
30
|
];
|
|
29
31
|
|
|
30
32
|
exports.TEST_OBSERVABILITY_REPORTER = 'browserstack-cypress-cli/bin/testObservability/reporter';
|
|
33
|
+
|
|
34
|
+
exports.TEST_OBSERVABILITY_REPORTER_LOCAL = path.join(__dirname, '..', 'reporter');
|
|
@@ -25,7 +25,15 @@ const GLOBAL_MODULE_PATH = execSync('npm root -g').toString().trim();
|
|
|
25
25
|
const { name, version } = require('../../../package.json');
|
|
26
26
|
|
|
27
27
|
const { CYPRESS_V10_AND_ABOVE_CONFIG_FILE_EXTENSIONS } = require('../../helpers/constants');
|
|
28
|
-
const { consoleHolder, API_URL, TEST_OBSERVABILITY_REPORTER } = require('./constants');
|
|
28
|
+
const { consoleHolder, API_URL, TEST_OBSERVABILITY_REPORTER, TEST_OBSERVABILITY_REPORTER_LOCAL } = require('./constants');
|
|
29
|
+
|
|
30
|
+
const ALLOWED_MODULES = [
|
|
31
|
+
'cypress/package.json',
|
|
32
|
+
'mocha/lib/reporters/base.js',
|
|
33
|
+
'mocha/lib/utils.js',
|
|
34
|
+
'mocha'
|
|
35
|
+
];
|
|
36
|
+
|
|
29
37
|
exports.pending_test_uploads = {
|
|
30
38
|
count: 0
|
|
31
39
|
};
|
|
@@ -331,7 +339,7 @@ exports.launchTestSession = async (user_config, bsConfigPath) => {
|
|
|
331
339
|
projectName,
|
|
332
340
|
buildDescription,
|
|
333
341
|
buildTags
|
|
334
|
-
} = helper.getBuildDetails(user_config);
|
|
342
|
+
} = helper.getBuildDetails(user_config, true);
|
|
335
343
|
const data = {
|
|
336
344
|
'format': 'json',
|
|
337
345
|
'project_name': projectName,
|
|
@@ -715,32 +723,85 @@ exports.getOSDetailsFromSystem = async (product) => {
|
|
|
715
723
|
};
|
|
716
724
|
}
|
|
717
725
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
726
|
+
let WORKSPACE_MODULE_PATH;
|
|
727
|
+
|
|
728
|
+
exports.requireModule = (module) => {
|
|
729
|
+
const modulePath = exports.resolveModule(module);
|
|
730
|
+
if (modulePath.error) {
|
|
731
|
+
throw new Error(`${module} doesn't exist.`);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
return require(modulePath.path);
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
exports.resolveModule = (module) => {
|
|
738
|
+
if (!ALLOWED_MODULES.includes(module)) {
|
|
739
|
+
throw new Error('Invalid module name');
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
if (WORKSPACE_MODULE_PATH == undefined) {
|
|
743
|
+
try {
|
|
744
|
+
WORKSPACE_MODULE_PATH = execSync('npm ls').toString().trim();
|
|
745
|
+
WORKSPACE_MODULE_PATH = WORKSPACE_MODULE_PATH.split('\n')[0].split(' ')[1];
|
|
746
|
+
} catch (e) {
|
|
747
|
+
WORKSPACE_MODULE_PATH = null;
|
|
748
|
+
exports.debug(`Could not locate npm module path with error ${e}`);
|
|
739
749
|
}
|
|
740
|
-
return require(global_path);
|
|
741
750
|
}
|
|
742
|
-
|
|
743
|
-
|
|
751
|
+
|
|
752
|
+
/*
|
|
753
|
+
Modules will be resolved in the following order,
|
|
754
|
+
current working dir > workspaces dir > NODE_PATH env var > global node modules path
|
|
755
|
+
*/
|
|
756
|
+
|
|
757
|
+
try {
|
|
758
|
+
exports.debug('requireModuleV2');
|
|
759
|
+
|
|
760
|
+
return {path: require.resolve(module), foundAt: 'resolve'};
|
|
761
|
+
} catch (_) {
|
|
762
|
+
/* Find from current working directory */
|
|
763
|
+
exports.debug(`Getting ${module} from ${process.cwd()}`);
|
|
764
|
+
let local_path = path.join(process.cwd(), 'node_modules', module);
|
|
765
|
+
if (!fs.existsSync(local_path)) {
|
|
766
|
+
exports.debug(`${module} doesn't exist at ${process.cwd()}`);
|
|
767
|
+
|
|
768
|
+
/* Find from workspaces */
|
|
769
|
+
if (WORKSPACE_MODULE_PATH) {
|
|
770
|
+
exports.debug(`Getting ${module} from path ${WORKSPACE_MODULE_PATH}`);
|
|
771
|
+
let workspace_path = null;
|
|
772
|
+
workspace_path = path.join(WORKSPACE_MODULE_PATH, 'node_modules', module);
|
|
773
|
+
if (workspace_path && fs.existsSync(workspace_path)) {
|
|
774
|
+
exports.debug(`Found ${module} from ${WORKSPACE_MODULE_PATH}`);
|
|
775
|
+
|
|
776
|
+
return {path: workspace_path, foundAt: 'workspaces'};
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/* Find from node path */
|
|
781
|
+
let node_path = null;
|
|
782
|
+
if (!exports.isUndefined(process.env.NODE_PATH)) {
|
|
783
|
+
node_path = path.join(process.env.NODE_PATH, module);
|
|
784
|
+
}
|
|
785
|
+
if (node_path && fs.existsSync(node_path)) {
|
|
786
|
+
exports.debug(`Getting ${module} from ${process.env.NODE_PATH}`);
|
|
787
|
+
|
|
788
|
+
return {path: node_path, foundAt: 'nodePath'};
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/* Find from global node modules path */
|
|
792
|
+
exports.debug(`Getting ${module} from ${GLOBAL_MODULE_PATH}`);
|
|
793
|
+
|
|
794
|
+
let global_path = path.join(GLOBAL_MODULE_PATH, module);
|
|
795
|
+
if (!global_path || !fs.existsSync(global_path)) {
|
|
796
|
+
return {error: 'module_not_found'};
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return {path: global_path, foundAt: 'local'};
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
return {path: local_path, foundAt: 'global'};
|
|
803
|
+
}
|
|
804
|
+
};
|
|
744
805
|
|
|
745
806
|
const getReRunSpecs = (rawArgs) => {
|
|
746
807
|
if (this.isTestObservabilitySession() && this.shouldReRunObservabilityTests()) {
|
|
@@ -763,7 +824,7 @@ const getReRunSpecs = (rawArgs) => {
|
|
|
763
824
|
|
|
764
825
|
const getLocalSessionReporter = () => {
|
|
765
826
|
if(this.isTestObservabilitySession() && process.env.BS_TESTOPS_JWT) {
|
|
766
|
-
return ['--reporter',
|
|
827
|
+
return ['--reporter', TEST_OBSERVABILITY_REPORTER_LOCAL];
|
|
767
828
|
} else {
|
|
768
829
|
return [];
|
|
769
830
|
}
|
|
@@ -156,14 +156,14 @@ class MyReporter {
|
|
|
156
156
|
})
|
|
157
157
|
|
|
158
158
|
.on(EVENT_TEST_BEGIN, async (test) => {
|
|
159
|
-
if (test.
|
|
159
|
+
if (this.runStatusMarkedHash[test.testAnalyticsId]) return;
|
|
160
160
|
if(this.testObservability == true) {
|
|
161
161
|
await this.testStarted(test);
|
|
162
162
|
}
|
|
163
163
|
})
|
|
164
164
|
|
|
165
165
|
.on(EVENT_TEST_END, async (test) => {
|
|
166
|
-
if (test.
|
|
166
|
+
if (this.runStatusMarkedHash[test.testAnalyticsId]) return;
|
|
167
167
|
if(this.testObservability == true) {
|
|
168
168
|
if(!this.runStatusMarkedHash[test.testAnalyticsId]) {
|
|
169
169
|
if(test.testAnalyticsId) this.runStatusMarkedHash[test.testAnalyticsId] = true;
|
|
@@ -448,7 +448,7 @@ class MyReporter {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
// Send pending hook finsihed events for hook starts
|
|
451
|
-
if (eventType === 'TestRunFinished') {
|
|
451
|
+
if (eventType === 'TestRunFinished' || eventType === 'TestRunSkipped') {
|
|
452
452
|
Object.values(this.hooksStarted).forEach(async hookData => {
|
|
453
453
|
hookData['event_type'] = 'HookRunFinished';
|
|
454
454
|
hookData['hook_run'] = {
|