browserstack-cypress-cli 1.17.0 → 1.19.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.
@@ -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 (cypressJson) {
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, cypressJson);
131
+ let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressConfigFile);
129
132
 
130
- bsConfig['run_settings']['video_config'] = utils.getVideoConfig(cypressJson);
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);
@@ -81,11 +81,19 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
81
81
  runSettings.cypress_config_file &&
82
82
  runSettings.cypress_config_filename !== 'false'
83
83
  ) {
84
- let cypressJSON = JSON.parse(
85
- fs.readFileSync(runSettings.cypressConfigFilePath)
86
- );
87
- let cypressJSONString = JSON.stringify(cypressJSON, null, 4);
88
- archive.append(cypressJSONString, {name: `${cypressAppendFilesZipLocation}cypress.json`});
84
+ if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
85
+ let cypressConfigFileString = fs.readFileSync(runSettings.cypressConfigFilePath, {encoding: "utf-8"});
86
+ for (const possibleCypressFileName of Constants.CYPRESS_CONFIG_FILE_NAMES) {
87
+ if (path.extname(runSettings.cypress_config_filename) == path.extname(possibleCypressFileName)) {
88
+ archive.append(cypressConfigFileString, {name: `${cypressAppendFilesZipLocation}${possibleCypressFileName}`});
89
+ break;
90
+ }
91
+ }
92
+ } else if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V9_AND_OLDER_TYPE) {
93
+ let cypressJSON = JSON.parse(fs.readFileSync(runSettings.cypressConfigFilePath));
94
+ let cypressJSONString = JSON.stringify(cypressJSON, null, 4);
95
+ archive.append(cypressJSONString, {name: `${cypressAppendFilesZipLocation}cypress.json`});
96
+ }
89
97
  }
90
98
 
91
99
  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 cypressJSON = utils.getCypressJSON(bsConfig);
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(cypressJSON !== undefined){
146
- reporter = cypressJSON.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.cypress_proj_dir && !bsConfig.run_settings.userProvidedCypessConfigFile) {
166
- reject(Constants.validationMessages.EMPTY_CYPRESS_PROJ_DIR);
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 cypressJson = {};
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
- logger.debug("Validating cypress.json");
198
- try {
199
- if (bsConfig.run_settings.cypress_config_filename !== 'false') {
200
- let cypressJsonContent = fs.readFileSync(cypressConfigFilePath);
201
- cypressJson = JSON.parse(cypressJsonContent);
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
- // Cypress Json Base Url & Local true check
204
- if (!Utils.isUndefined(cypressJson.baseUrl) && cypressJson.baseUrl.includes("localhost") && !Utils.getLocalFlag(bsConfig.connection_settings)) reject(Constants.validationMessages.LOCAL_NOT_SET.replace("<baseUrlValue>", cypressJson.baseUrl));
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
- // Detect if the user is not using the right directory structure, and throw an error
207
- if (!Utils.isUndefined(cypressJson.integrationFolder) && !Utils.isCypressProjDirValid(bsConfig.run_settings.cypressProjectDir,cypressJson.integrationFolder)) reject(Constants.validationMessages.INCORRECT_DIRECTORY_STRUCTURE);
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) || path.extname(possibleCypressFileName) == path.extname(bsConfig.run_settings.cypress_config_filename)) {
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(cypressJson);
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 cypressJSON = JSON.parse(
41
- fs.readFileSync(runSettings.cypressConfigFilePath)
42
- );
43
- let cypressJSONString = JSON.stringify(cypressJSON);
44
- outputHash.update(cypressJSONString);
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) {
@@ -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
- CYPRESS_JSON_NOT_FOUND:
131
- "cypress.json file is not found at cypress_proj_dir path ",
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",
@@ -302,6 +306,8 @@ const allowedFileTypes = [
302
306
  "pmc",
303
307
  "pmp",
304
308
  "max",
309
+ "mjpeg",
310
+ "y4m"
305
311
  ];
306
312
 
307
313
  const filesToIgnoreWhileUploading = [
@@ -312,13 +318,17 @@ const filesToIgnoreWhileUploading = [
312
318
  "browserstack-package.json",
313
319
  "tests.zip",
314
320
  "cypress.json",
321
+ "cypress.config.js",
322
+ "cypress.config.ts",
323
+ "cypress.config.cjs",
324
+ "cypress.config.mjs",
315
325
  ".idea/**",
316
326
  ".vscode/**",
317
327
  ".npm/**",
318
328
  "bstackPackages.tar.gz",
319
329
  "tmpBstackPackages/**",
320
330
  ".yarn/**",
321
- "build_artifacts/**",
331
+ "build_artifacts/**"
322
332
  ];
323
333
 
324
334
  const readDirOptions = {
@@ -376,6 +386,30 @@ const SPEC_TIMEOUT_LIMIT = 120; // IN MINS
376
386
 
377
387
  const CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY = "custom_errors_to_print";
378
388
 
389
+ const CYPRESS_V9_AND_OLDER_TYPE = "CYPRESS_V9_AND_OLDER_TYPE";
390
+
391
+ const CYPRESS_V10_AND_ABOVE_TYPE = "CYPRESS_V10_AND_ABOVE_TYPE";
392
+
393
+ const CYPRESS_CONFIG_FILE_MAPPING = {
394
+ "cypress.json": {
395
+ type: CYPRESS_V9_AND_OLDER_TYPE
396
+ },
397
+ "cypress.config.js": {
398
+ type: CYPRESS_V10_AND_ABOVE_TYPE
399
+ },
400
+ "cypress.config.ts": {
401
+ type: CYPRESS_V10_AND_ABOVE_TYPE
402
+ },
403
+ "cypress.config.mjs": {
404
+ type: CYPRESS_V10_AND_ABOVE_TYPE
405
+ },
406
+ "cypress.config.cjs": {
407
+ type: CYPRESS_V10_AND_ABOVE_TYPE
408
+ }
409
+ };
410
+
411
+ const CYPRESS_CONFIG_FILE_NAMES = Object.keys(CYPRESS_CONFIG_FILE_MAPPING);
412
+
379
413
  module.exports = Object.freeze({
380
414
  syncCLI,
381
415
  userMessages,
@@ -402,4 +436,8 @@ module.exports = Object.freeze({
402
436
  BUILD_FAILED_EXIT_CODE,
403
437
  SPEC_TIMEOUT_LIMIT,
404
438
  CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY,
439
+ CYPRESS_V9_AND_OLDER_TYPE,
440
+ CYPRESS_V10_AND_ABOVE_TYPE,
441
+ CYPRESS_CONFIG_FILE_MAPPING,
442
+ CYPRESS_CONFIG_FILE_NAMES
405
443
  });
@@ -61,9 +61,9 @@ function bstack_json_found_in_pwd() {
61
61
  }
62
62
  }
63
63
 
64
- function cypress_json_found_in_pwd() {
64
+ function cypress_config_file_found_in_pwd(cypress_config_filename) {
65
65
  try {
66
- if (fs.existsSync(path.join(process.cwd(), 'cypress.json'))) {
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
- cypress_json_found_in_pwd: cypress_json_found_in_pwd(),
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(),
@@ -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,11 +291,41 @@ 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
- bsConfig.run_settings.cypressConfigFilePath = path.join(bsConfig.run_settings.cypress_proj_dir, 'cypress.json');
292
- bsConfig.run_settings.cypressProjectDir = bsConfig.run_settings.cypress_proj_dir;
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
- logger.debug(`Setting cypress project dir = ${bsConfig.run_settings.cypressProjDir}`);
311
+ logger.debug(`Setting cypress project dir = ${bsConfig.run_settings.cypressProjectDir}`);
312
+ }
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
+ (path.extname(bsConfig.run_settings.cypressConfigFilePath) == path.extname(possibleCypressFileName) || 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}`);
296
329
  }
297
330
 
298
331
  exports.verifyGeolocationOption = () => {
@@ -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 cypressJson = this.getCypressJSON(bsConfig);
364
- if (!this.isUndefined(cypressJson) && !this.isUndefined(cypressJson["projectId"])) { return cypressJson["projectId"]; }
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, cypressJson) => {
935
- let testFolderPath = cypressJson.integrationFolder || Constants.DEFAULT_CYPRESS_SPEC_PATH;
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.getCypressJSON = (bsConfig) => {
1094
- let cypressJSON = undefined;
1095
- if (bsConfig.run_settings.cypress_config_file && bsConfig.run_settings.cypress_config_filename !== 'false') {
1096
- cypressJSON = JSON.parse(
1097
- fs.readFileSync(bsConfig.run_settings.cypressConfigFilePath)
1098
- );
1099
- } else if (bsConfig.run_settings.cypressProjectDir) {
1100
- cypressJSON = JSON.parse(
1101
- fs.readFileSync(path.join(bsConfig.run_settings.cypressProjectDir, 'cypress.json'))
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 cypressJSON;
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 = (cypressJson) => {
1281
+ exports.getVideoConfig = (cypressConfig) => {
1239
1282
  let conf = {
1240
1283
  video: true,
1241
1284
  videoUploadOnPasses: true
1242
1285
  }
1243
- if (!this.isUndefined(cypressJson.video)) conf.video = cypressJson.video;
1244
- if (!this.isUndefined(cypressJson.videoUploadOnPasses)) conf.videoUploadOnPasses = cypressJson.videoUploadOnPasses;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.17.0",
3
+ "version": "1.19.0",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
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"}