browserstack-cypress-cli 1.17.0 → 1.18.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/bin/commands/runs.js +6 -3
- package/bin/helpers/archiver.js +8 -5
- package/bin/helpers/buildArtifacts.js +3 -3
- package/bin/helpers/capabilityHelper.js +47 -15
- package/bin/helpers/checkUploaded.js +8 -5
- package/bin/helpers/constants.js +39 -3
- package/bin/helpers/usageReporting.js +3 -3
- package/bin/helpers/utils.js +63 -20
- package/bin/runner.js +1 -1
- package/package.json +1 -1
- package/log/usage.log +0 -2
package/bin/commands/runs.js
CHANGED
|
@@ -61,6 +61,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
61
61
|
// set cypress config filename
|
|
62
62
|
utils.setCypressConfigFilename(bsConfig, args);
|
|
63
63
|
|
|
64
|
+
// set cypress test suite type
|
|
65
|
+
utils.setCypressTestSuiteType(bsConfig);
|
|
66
|
+
|
|
64
67
|
// set cypress geo location
|
|
65
68
|
utils.setGeolocation(bsConfig, args);
|
|
66
69
|
|
|
@@ -119,15 +122,15 @@ module.exports = function run(args, rawArgs) {
|
|
|
119
122
|
// Validate browserstack.json values and parallels specified via arguments
|
|
120
123
|
markBlockStart('validateConfig');
|
|
121
124
|
logger.debug("Started configs validation");
|
|
122
|
-
return capabilityHelper.validate(bsConfig, args).then(function (
|
|
125
|
+
return capabilityHelper.validate(bsConfig, args).then(function (cypressConfigFile) {
|
|
123
126
|
markBlockEnd('validateConfig');
|
|
124
127
|
logger.debug("Completed configs validation");
|
|
125
128
|
markBlockStart('preArchiveSteps');
|
|
126
129
|
logger.debug("Started pre-archive steps");
|
|
127
130
|
//get the number of spec files
|
|
128
|
-
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args,
|
|
131
|
+
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressConfigFile);
|
|
129
132
|
|
|
130
|
-
bsConfig['run_settings']['video_config'] = utils.getVideoConfig(
|
|
133
|
+
bsConfig['run_settings']['video_config'] = utils.getVideoConfig(cypressConfigFile);
|
|
131
134
|
|
|
132
135
|
// return the number of parallels user specified
|
|
133
136
|
let userSpecifiedParallels = utils.getParallels(bsConfig, args);
|
package/bin/helpers/archiver.js
CHANGED
|
@@ -81,11 +81,14 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
81
81
|
runSettings.cypress_config_file &&
|
|
82
82
|
runSettings.cypress_config_filename !== 'false'
|
|
83
83
|
) {
|
|
84
|
-
|
|
85
|
-
fs.readFileSync(runSettings.cypressConfigFilePath)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
85
|
+
let cypressConfigFileString = fs.readFileSync(runSettings.cypressConfigFilePath, {encoding: "utf-8"});
|
|
86
|
+
archive.append(cypressConfigFileString, {name: `${cypressAppendFilesZipLocation}${runSettings.cypress_config_filename}`});
|
|
87
|
+
} else if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V9_AND_OLDER_TYPE) {
|
|
88
|
+
let cypressJSON = JSON.parse(fs.readFileSync(runSettings.cypressConfigFilePath));
|
|
89
|
+
let cypressJSONString = JSON.stringify(cypressJSON, null, 4);
|
|
90
|
+
archive.append(cypressJSONString, {name: `${cypressAppendFilesZipLocation}cypress.json`});
|
|
91
|
+
}
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
archive.finalize();
|
|
@@ -137,13 +137,13 @@ const unzipFile = async (filePath, fileName) => {
|
|
|
137
137
|
const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, buildReportData) => {
|
|
138
138
|
options.url = `${config.buildUrl}${buildId}/build_artifacts/status`;
|
|
139
139
|
|
|
140
|
-
let
|
|
140
|
+
let cypressConfigFile = utils.getCypressConfigFile(bsConfig);
|
|
141
141
|
|
|
142
142
|
let reporter = null;
|
|
143
143
|
if(!utils.isUndefined(args.reporter)) {
|
|
144
144
|
reporter = args.reporter;
|
|
145
|
-
} else if(
|
|
146
|
-
reporter =
|
|
145
|
+
} else if(cypressConfigFile !== undefined){
|
|
146
|
+
reporter = cypressConfigFile.reporter;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
let data = {
|
|
@@ -162,8 +162,8 @@ const validate = (bsConfig, args) => {
|
|
|
162
162
|
|
|
163
163
|
if (!bsConfig.run_settings) reject(Constants.validationMessages.EMPTY_RUN_SETTINGS);
|
|
164
164
|
|
|
165
|
-
if (!bsConfig.run_settings.
|
|
166
|
-
reject(Constants.validationMessages.
|
|
165
|
+
if (!bsConfig.run_settings.cypressConfigFilePath && !bsConfig.run_settings.userProvidedCypessConfigFile) {
|
|
166
|
+
reject(Constants.validationMessages.EMPTY_CYPRESS_CONFIG_FILE);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// validate parallels specified in browserstack.json if parallels are not specified via arguments
|
|
@@ -189,25 +189,39 @@ const validate = (bsConfig, args) => {
|
|
|
189
189
|
// validate if config file provided exists or not when cypress_config_file provided
|
|
190
190
|
// validate the cypressProjectDir key otherwise.
|
|
191
191
|
let cypressConfigFilePath = bsConfig.run_settings.cypressConfigFilePath;
|
|
192
|
-
let
|
|
192
|
+
let cypressConfigFile = {};
|
|
193
193
|
|
|
194
194
|
logger.debug(`Checking for cypress config file at ${cypressConfigFilePath}`);
|
|
195
195
|
if (!fs.existsSync(cypressConfigFilePath) && bsConfig.run_settings.cypress_config_filename !== 'false') reject(Constants.validationMessages.INVALID_CYPRESS_CONFIG_FILE);
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
if (bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
198
|
+
logger.debug(`Validating ${bsConfig.run_settings.cypress_config_filename}`);
|
|
199
|
+
// TODO: add validations for cypress_config_filename
|
|
200
|
+
} else {
|
|
201
|
+
logger.debug("Validating cypress.json");
|
|
202
|
+
try {
|
|
203
|
+
if (bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
204
|
+
|
|
205
|
+
if (bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
206
|
+
if (cypressConfigFilePath.endsWith("cypress.config.js")) {
|
|
207
|
+
cypressConfigFile = require(cypressConfigFilePath);
|
|
208
|
+
} else {
|
|
209
|
+
cypressConfigFile = {};
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
let cypressJsonContent = fs.readFileSync(cypressConfigFilePath);
|
|
213
|
+
cypressConfigFile = JSON.parse(cypressJsonContent);
|
|
214
|
+
}
|
|
202
215
|
|
|
203
|
-
|
|
204
|
-
|
|
216
|
+
// Cypress Json Base Url & Local true check
|
|
217
|
+
if (!Utils.isUndefined(cypressConfigFile.baseUrl) && cypressConfigFile.baseUrl.includes("localhost") && !Utils.getLocalFlag(bsConfig.connection_settings)) reject(Constants.validationMessages.LOCAL_NOT_SET.replace("<baseUrlValue>", cypressConfigFile.baseUrl));
|
|
205
218
|
|
|
206
|
-
|
|
207
|
-
|
|
219
|
+
// Detect if the user is not using the right directory structure, and throw an error
|
|
220
|
+
if (!Utils.isUndefined(cypressConfigFile.integrationFolder) && !Utils.isCypressProjDirValid(bsConfig.run_settings.cypressProjectDir,cypressConfigFile.integrationFolder)) reject(Constants.validationMessages.INCORRECT_DIRECTORY_STRUCTURE);
|
|
221
|
+
}
|
|
222
|
+
} catch(error){
|
|
223
|
+
reject(Constants.validationMessages.INVALID_CYPRESS_JSON)
|
|
208
224
|
}
|
|
209
|
-
} catch(error){
|
|
210
|
-
reject(Constants.validationMessages.INVALID_CYPRESS_JSON)
|
|
211
225
|
}
|
|
212
226
|
|
|
213
227
|
//check if home_directory is present or not in user run_settings
|
|
@@ -231,6 +245,24 @@ const validate = (bsConfig, args) => {
|
|
|
231
245
|
addCypressZipStartLocation(bsConfig.run_settings);
|
|
232
246
|
}
|
|
233
247
|
|
|
248
|
+
// check if two config files are present at the same location
|
|
249
|
+
let cypressFileDirectory = path.dirname(path.resolve(bsConfig.run_settings.cypressConfigFilePath));
|
|
250
|
+
let listOfFiles = fs.readdirSync(cypressFileDirectory);
|
|
251
|
+
let configFilesPresent = [];
|
|
252
|
+
for (const possibleCypressFileName of Constants.CYPRESS_CONFIG_FILE_NAMES) {
|
|
253
|
+
if (listOfFiles.includes(possibleCypressFileName)) {
|
|
254
|
+
configFilesPresent.push(possibleCypressFileName);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (configFilesPresent.length === 0 && bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
259
|
+
reject(Constants.validationMessages.CYPRESS_CONFIG_FILE_NOT_FOUND.replace('<location>', cypressFileDirectory));
|
|
260
|
+
}
|
|
261
|
+
if (configFilesPresent.length > 1 && bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
262
|
+
logger.warn(`We found the following cypress config files ${configFilesPresent.join(', ')} at this location: ${cypressFileDirectory}`);
|
|
263
|
+
reject(Constants.validationMessages.MORE_THAN_ONE_CYPRESS_CONFIG_FILE_FOUND);
|
|
264
|
+
}
|
|
265
|
+
|
|
234
266
|
if(!Utils.isUndefined(bsConfig.run_settings.spec_timeout)) {
|
|
235
267
|
if(Utils.isPositiveInteger(bsConfig.run_settings.spec_timeout.toString().trim())) {
|
|
236
268
|
if(Number(bsConfig.run_settings.spec_timeout) > Constants.SPEC_TIMEOUT_LIMIT) {
|
|
@@ -257,7 +289,7 @@ const validate = (bsConfig, args) => {
|
|
|
257
289
|
if (!Utils.isUndefined(bsConfig.run_settings.nodeVersion) && typeof(bsConfig.run_settings.nodeVersion) === 'string' && !bsConfig.run_settings.nodeVersion.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/))
|
|
258
290
|
logger.warn(Constants.validationMessages.NODE_VERSION_PARSING_ERROR);
|
|
259
291
|
|
|
260
|
-
resolve(
|
|
292
|
+
resolve(cypressConfigFile);
|
|
261
293
|
});
|
|
262
294
|
}
|
|
263
295
|
|
|
@@ -37,11 +37,14 @@ const checkSpecsMd5 = (runSettings, args, instrumentBlocks) => {
|
|
|
37
37
|
runSettings.cypress_config_file &&
|
|
38
38
|
runSettings.cypress_config_filename !== 'false'
|
|
39
39
|
) {
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
let cypressConfigFileString = "";
|
|
41
|
+
if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
42
|
+
cypressConfigFileString = fs.readFileSync(runSettings.cypressConfigFilePath).toString();
|
|
43
|
+
} else {
|
|
44
|
+
let cypressJSON = JSON.parse(fs.readFileSync(runSettings.cypressConfigFilePath));
|
|
45
|
+
cypressConfigFileString = JSON.stringify(cypressJSON);
|
|
46
|
+
}
|
|
47
|
+
outputHash.update(cypressConfigFileString);
|
|
45
48
|
}
|
|
46
49
|
resolve(outputHash.digest(Constants.hashingOptions.encoding));
|
|
47
50
|
}).catch(function (error) {
|
package/bin/helpers/constants.js
CHANGED
|
@@ -120,6 +120,8 @@ const validationMessages = {
|
|
|
120
120
|
EMPTY_RUN_SETTINGS: "Empty run settings",
|
|
121
121
|
EMPTY_CYPRESS_PROJ_DIR:
|
|
122
122
|
"cypress_proj_dir is not set in run_settings. See https://www.browserstack.com/docs/automate/cypress/sample-tutorial to learn more.",
|
|
123
|
+
EMPTY_CYPRESS_CONFIG_FILE:
|
|
124
|
+
"cypress_config_file is not set in run_settings. See https://www.browserstack.com/docs/automate/cypress/configuration-file to learn more.",
|
|
123
125
|
VALIDATED: "browserstack.json file is validated",
|
|
124
126
|
NOT_VALID: "browerstack.json is not valid",
|
|
125
127
|
NOT_VALID_JSON: "browerstack.json is not a valid json",
|
|
@@ -127,8 +129,10 @@ const validationMessages = {
|
|
|
127
129
|
INVALID_PARALLELS_CONFIGURATION:
|
|
128
130
|
"Invalid value specified for parallels to use. Maximum parallels to use should be a number greater than 0.",
|
|
129
131
|
INVALID_CYPRESS_CONFIG_FILE: "Invalid cypress_config_file",
|
|
130
|
-
|
|
131
|
-
"cypress
|
|
132
|
+
CYPRESS_CONFIG_FILE_NOT_FOUND:
|
|
133
|
+
"No cypress config file was found at <location> directory.",
|
|
134
|
+
MORE_THAN_ONE_CYPRESS_CONFIG_FILE_FOUND:
|
|
135
|
+
"Cypress does not allow more than one cypress config file.",
|
|
132
136
|
INVALID_CYPRESS_JSON: "cypress.json is not a valid json",
|
|
133
137
|
INVALID_DEFAULT_AUTH_PARAMS:
|
|
134
138
|
"Your username and access key are required to run your tests on BrowserStack. Learn more at https://www.browserstack.com/docs/automate/cypress/authentication",
|
|
@@ -312,13 +316,17 @@ const filesToIgnoreWhileUploading = [
|
|
|
312
316
|
"browserstack-package.json",
|
|
313
317
|
"tests.zip",
|
|
314
318
|
"cypress.json",
|
|
319
|
+
"cypress.config.js",
|
|
320
|
+
"cypress.config.ts",
|
|
321
|
+
"cypress.config.cjs",
|
|
322
|
+
"cypress.config.mjs",
|
|
315
323
|
".idea/**",
|
|
316
324
|
".vscode/**",
|
|
317
325
|
".npm/**",
|
|
318
326
|
"bstackPackages.tar.gz",
|
|
319
327
|
"tmpBstackPackages/**",
|
|
320
328
|
".yarn/**",
|
|
321
|
-
"build_artifacts/**"
|
|
329
|
+
"build_artifacts/**"
|
|
322
330
|
];
|
|
323
331
|
|
|
324
332
|
const readDirOptions = {
|
|
@@ -376,6 +384,30 @@ const SPEC_TIMEOUT_LIMIT = 120; // IN MINS
|
|
|
376
384
|
|
|
377
385
|
const CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY = "custom_errors_to_print";
|
|
378
386
|
|
|
387
|
+
const CYPRESS_V9_AND_OLDER_TYPE = "CYPRESS_V9_AND_OLDER_TYPE";
|
|
388
|
+
|
|
389
|
+
const CYPRESS_V10_AND_ABOVE_TYPE = "CYPRESS_V10_AND_ABOVE_TYPE";
|
|
390
|
+
|
|
391
|
+
const CYPRESS_CONFIG_FILE_MAPPING = {
|
|
392
|
+
"cypress.json": {
|
|
393
|
+
type: CYPRESS_V9_AND_OLDER_TYPE
|
|
394
|
+
},
|
|
395
|
+
"cypress.config.js": {
|
|
396
|
+
type: CYPRESS_V10_AND_ABOVE_TYPE
|
|
397
|
+
},
|
|
398
|
+
"cypress.config.ts": {
|
|
399
|
+
type: CYPRESS_V10_AND_ABOVE_TYPE
|
|
400
|
+
},
|
|
401
|
+
"cypress.config.mjs": {
|
|
402
|
+
type: CYPRESS_V10_AND_ABOVE_TYPE
|
|
403
|
+
},
|
|
404
|
+
"cypress.config.cjs": {
|
|
405
|
+
type: CYPRESS_V10_AND_ABOVE_TYPE
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const CYPRESS_CONFIG_FILE_NAMES = Object.keys(CYPRESS_CONFIG_FILE_MAPPING);
|
|
410
|
+
|
|
379
411
|
module.exports = Object.freeze({
|
|
380
412
|
syncCLI,
|
|
381
413
|
userMessages,
|
|
@@ -402,4 +434,8 @@ module.exports = Object.freeze({
|
|
|
402
434
|
BUILD_FAILED_EXIT_CODE,
|
|
403
435
|
SPEC_TIMEOUT_LIMIT,
|
|
404
436
|
CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY,
|
|
437
|
+
CYPRESS_V9_AND_OLDER_TYPE,
|
|
438
|
+
CYPRESS_V10_AND_ABOVE_TYPE,
|
|
439
|
+
CYPRESS_CONFIG_FILE_MAPPING,
|
|
440
|
+
CYPRESS_CONFIG_FILE_NAMES
|
|
405
441
|
});
|
|
@@ -61,9 +61,9 @@ function bstack_json_found_in_pwd() {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
function
|
|
64
|
+
function cypress_config_file_found_in_pwd(cypress_config_filename) {
|
|
65
65
|
try {
|
|
66
|
-
if (fs.existsSync(path.join(process.cwd(),
|
|
66
|
+
if (fs.existsSync(path.join(process.cwd(), cypress_config_filename))) {
|
|
67
67
|
//file exists
|
|
68
68
|
return true;
|
|
69
69
|
}
|
|
@@ -244,7 +244,7 @@ function send(args) {
|
|
|
244
244
|
os: _os(),
|
|
245
245
|
os_version: os_version(),
|
|
246
246
|
bstack_json_found_in_pwd: bstack_json_found_in_pwd(),
|
|
247
|
-
|
|
247
|
+
cypress_config_file_found_in_pwd: cypress_config_file_found_in_pwd(runSettings.cypress_config_filename),
|
|
248
248
|
cli_version: cli_details.version,
|
|
249
249
|
cli_path: cli_details.path,
|
|
250
250
|
npm_version: npm_version(),
|
package/bin/helpers/utils.js
CHANGED
|
@@ -57,6 +57,9 @@ exports.getErrorCodeFromMsg = (errMsg) => {
|
|
|
57
57
|
case Constants.validationMessages.EMPTY_CYPRESS_PROJ_DIR:
|
|
58
58
|
errorCode = 'bstack_json_invalid_no_cypress_proj_dir';
|
|
59
59
|
break;
|
|
60
|
+
case Constants.validationMessages.EMPTY_CYPRESS_CONFIG_FILE:
|
|
61
|
+
errorCode = 'bstack_json_invalid_no_cypress_config_file';
|
|
62
|
+
break;
|
|
60
63
|
case Constants.validationMessages.INVALID_DEFAULT_AUTH_PARAMS:
|
|
61
64
|
errorCode = 'bstack_json_default_auth_keys';
|
|
62
65
|
break;
|
|
@@ -288,13 +291,43 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
|
|
|
288
291
|
bsConfig.run_settings.cypressConfigFilePath = bsConfig.run_settings.cypress_config_file;
|
|
289
292
|
bsConfig.run_settings.cypressProjectDir = path.dirname(bsConfig.run_settings.cypress_config_file);
|
|
290
293
|
} else {
|
|
291
|
-
|
|
292
|
-
|
|
294
|
+
logger.debug(`Looks like cypress config file was not provided. Looking for ${Constants.CYPRESS_CONFIG_FILE_NAMES.join(", ")} files at ${process.cwd()}`);
|
|
295
|
+
for (const possibleCypressFileName of Constants.CYPRESS_CONFIG_FILE_NAMES) {
|
|
296
|
+
let directoryPath = !this.isUndefined(bsConfig.run_settings.cypress_proj_dir) ? bsConfig.run_settings.cypress_proj_dir : process.cwd();
|
|
297
|
+
if (directoryPath.endsWith("/")) {
|
|
298
|
+
directoryPath = directoryPath.slice(0,-1);
|
|
299
|
+
}
|
|
300
|
+
if (fs.existsSync(path.join(directoryPath, possibleCypressFileName))) {
|
|
301
|
+
bsConfig.run_settings.cypressConfigFilePath = `${directoryPath}/${possibleCypressFileName}`;
|
|
302
|
+
bsConfig.run_settings.cypress_config_file = `${directoryPath}/${possibleCypressFileName}`;
|
|
303
|
+
bsConfig.run_settings.cypress_config_filename = path.basename(bsConfig.run_settings.cypress_config_file);
|
|
304
|
+
bsConfig.run_settings.cypressProjectDir = directoryPath;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
293
308
|
}
|
|
309
|
+
|
|
294
310
|
logger.debug(`Setting cypress config file path = ${bsConfig.run_settings.cypressConfigFilePath}`);
|
|
295
311
|
logger.debug(`Setting cypress project dir = ${bsConfig.run_settings.cypressProjDir}`);
|
|
296
312
|
}
|
|
297
313
|
|
|
314
|
+
exports.setCypressTestSuiteType = (bsConfig) => {
|
|
315
|
+
for (const possibleCypressFileName of Constants.CYPRESS_CONFIG_FILE_NAMES) {
|
|
316
|
+
if (bsConfig.run_settings.cypressConfigFilePath &&
|
|
317
|
+
typeof(bsConfig.run_settings.cypressConfigFilePath) === 'string' &&
|
|
318
|
+
bsConfig.run_settings.cypressConfigFilePath.endsWith(possibleCypressFileName)) {
|
|
319
|
+
bsConfig.run_settings.cypressTestSuiteType = Constants.CYPRESS_CONFIG_FILE_MAPPING[possibleCypressFileName].type;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (this.isUndefined(bsConfig.run_settings.cypressTestSuiteType)) {
|
|
325
|
+
bsConfig.run_settings.cypressTestSuiteType = Constants.CYPRESS_V9_AND_OLDER_TYPE;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
logger.debug(`Setting cypress test suite type as ${bsConfig.run_settings.cypressTestSuiteType}`);
|
|
329
|
+
}
|
|
330
|
+
|
|
298
331
|
exports.verifyGeolocationOption = () => {
|
|
299
332
|
let glOptionsSet = (this.searchForOption('-gl') || this.searchForOption('--gl'));
|
|
300
333
|
let geoHyphenLocationOptionsSet = (this.searchForOption('-geo-location') || this.searchForOption('--geo-location'));
|
|
@@ -360,8 +393,10 @@ exports.setProjectId = (bsConfig, args) => {
|
|
|
360
393
|
} else if(!this.isUndefined(bsConfig.run_settings["projectId"])) {
|
|
361
394
|
return bsConfig.run_settings["projectId"];
|
|
362
395
|
} else {
|
|
363
|
-
let
|
|
364
|
-
if (!this.isUndefined(
|
|
396
|
+
let cypressConfigFile = this.getCypressConfigFile(bsConfig);
|
|
397
|
+
if (!this.isUndefined(cypressConfigFile) && !this.isUndefined(cypressConfigFile["projectId"])) {
|
|
398
|
+
return cypressConfigFile["projectId"];
|
|
399
|
+
}
|
|
365
400
|
}
|
|
366
401
|
}
|
|
367
402
|
|
|
@@ -931,8 +966,8 @@ exports.getFilesToIgnore = (runSettings, excludeFiles, logging = true) => {
|
|
|
931
966
|
return ignoreFiles;
|
|
932
967
|
}
|
|
933
968
|
|
|
934
|
-
exports.getNumberOfSpecFiles = (bsConfig, args,
|
|
935
|
-
let testFolderPath =
|
|
969
|
+
exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig) => {
|
|
970
|
+
let testFolderPath = cypressConfig.integrationFolder || Constants.DEFAULT_CYPRESS_SPEC_PATH;
|
|
936
971
|
let globSearchPattern = this.sanitizeSpecsPattern(bsConfig.run_settings.specs) || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`;
|
|
937
972
|
let ignoreFiles = args.exclude || bsConfig.run_settings.exclude;
|
|
938
973
|
let files = glob.sync(globSearchPattern, {cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles});
|
|
@@ -1090,18 +1125,26 @@ exports.readBsConfigJSON = (bsConfigPath) => {
|
|
|
1090
1125
|
}
|
|
1091
1126
|
}
|
|
1092
1127
|
|
|
1093
|
-
exports.
|
|
1094
|
-
let
|
|
1095
|
-
if (bsConfig.run_settings.
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1128
|
+
exports.getCypressConfigFile = (bsConfig) => {
|
|
1129
|
+
let cypressConfigFile = undefined;
|
|
1130
|
+
if (bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
1131
|
+
if (bsConfig.run_settings.cypress_config_filename.endsWith("cypress.config.js")) {
|
|
1132
|
+
if (bsConfig.run_settings.cypress_config_file && bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
1133
|
+
cypressConfigFile = require(path.resolve(bsConfig.run_settings.cypressConfigFilePath));
|
|
1134
|
+
} else if (bsConfig.run_settings.cypressProjectDir) {
|
|
1135
|
+
cypressConfigFile = require(path.join(bsConfig.run_settings.cypressProjectDir, bsConfig.run_settings.cypress_config_filename));
|
|
1136
|
+
}
|
|
1137
|
+
} else {
|
|
1138
|
+
cypressConfigFile = {};
|
|
1139
|
+
}
|
|
1140
|
+
} else {
|
|
1141
|
+
if (bsConfig.run_settings.cypress_config_file && bsConfig.run_settings.cypress_config_filename !== 'false') {
|
|
1142
|
+
cypressConfigFile = JSON.parse(fs.readFileSync(bsConfig.run_settings.cypressConfigFilePath))
|
|
1143
|
+
} else if (bsConfig.run_settings.cypressProjectDir) {
|
|
1144
|
+
cypressConfigFile = JSON.parse(fs.readFileSync(path.join(bsConfig.run_settings.cypressProjectDir, bsConfig.run_settings.cypress_config_filename)));
|
|
1145
|
+
}
|
|
1103
1146
|
}
|
|
1104
|
-
return
|
|
1147
|
+
return cypressConfigFile;
|
|
1105
1148
|
}
|
|
1106
1149
|
|
|
1107
1150
|
exports.setCLIMode = (bsConfig, args) => {
|
|
@@ -1235,13 +1278,13 @@ exports.fetchZipSize = (fileName) => {
|
|
|
1235
1278
|
}
|
|
1236
1279
|
}
|
|
1237
1280
|
|
|
1238
|
-
exports.getVideoConfig = (
|
|
1281
|
+
exports.getVideoConfig = (cypressConfig) => {
|
|
1239
1282
|
let conf = {
|
|
1240
1283
|
video: true,
|
|
1241
1284
|
videoUploadOnPasses: true
|
|
1242
1285
|
}
|
|
1243
|
-
if (!this.isUndefined(
|
|
1244
|
-
if (!this.isUndefined(
|
|
1286
|
+
if (!this.isUndefined(cypressConfig.video)) conf.video = cypressConfig.video;
|
|
1287
|
+
if (!this.isUndefined(cypressConfig.videoUploadOnPasses)) conf.videoUploadOnPasses = cypressConfig.videoUploadOnPasses;
|
|
1245
1288
|
|
|
1246
1289
|
logger.debug(`Setting video = ${conf.video}`);
|
|
1247
1290
|
logger.debug(`Setting videoUploadOnPasses = ${conf.videoUploadOnPasses}`);
|
package/bin/runner.js
CHANGED
package/package.json
CHANGED
package/log/usage.log
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
{"level":"info","message":"Sending {\"event_type\":\"cypress_cli_stats\",\"data\":{\"bstack_json\":\"null\",\"run_settings\":\"\",\"os\":\"darwin\",\"os_version\":\"21.4.0\",\"bstack_json_found_in_pwd\":false,\"cypress_json_found_in_pwd\":false,\"cli_version\":\"1.13.0\",\"cli_path\":\"/Users/rahulnwn/.nvm/versions/node/v12.18.4/lib/node_modules\",\"npm_version\":\"6.14.6\",\"local_cypress_version\":null,\"ci_environment\":null,\"event_timestamp\":\"4/13/2022, 12:39:15 AM\",\"data\":null,\"raw_args\":[\"run\"],\"cli_args\":{\"_\":[\"run\"],\"cf\":\"browserstack.json\",\"config-file\":\"browserstack.json\",\"configFile\":\"browserstack.json\",\"ccf\":\"./cypress.json\",\"cypress-config-file\":\"./cypress.json\",\"cypressConfigFile\":\"./cypress.json\",\"disable-npm-warning\":false,\"disableNpmWarning\":false,\"sync\":true,\"async\":false,\"force-upload\":false,\"forceUpload\":false,\"headed\":false,\"no-wrap\":false,\"noWrap\":false,\"$0\":\"browserstack-cypress\"},\"message_type\":\"error\",\"error_code\":\"bstack_json_invalid_unknown\"}} to http://127.0.0.1:8000/send_event_cy_internal","timestamp":"2022-04-12T19:09:15.315Z"}
|
|
2
|
-
{"level":"info","message":"{\"attempts\":1,\"statusCode\":404}","timestamp":"2022-04-12T19:09:15.365Z"}
|