browserstack-cypress-cli 1.21.0 → 1.22.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.
Files changed (36) hide show
  1. package/.nyc_output/2807648c-3b13-4cd1-b949-11ce1b846277.json +1 -0
  2. package/.nyc_output/48e04c5a-5723-4547-b9d6-20074786acab.json +1 -0
  3. package/.nyc_output/51e8de95-1005-492b-8e2f-d7c6fc9148e4.json +1 -0
  4. package/.nyc_output/577e3334-ad22-4b05-ac7f-e0038582bb25.json +1 -0
  5. package/.nyc_output/59cc8cf4-849a-4cb5-bc52-0133091e0584.json +1 -0
  6. package/.nyc_output/5fc28c76-8c92-44e9-9bae-ec2e85892509.json +1 -0
  7. package/.nyc_output/5fffbcf8-4572-45c7-948f-38aeb3421a3e.json +1 -0
  8. package/.nyc_output/6b02b68b-ad99-40ff-b34f-218d98a9c773.json +1 -0
  9. package/.nyc_output/6ec27c2e-3529-412c-a82b-d1b8970a52a5.json +1 -0
  10. package/.nyc_output/7540c691-20e7-4eb9-a21e-75f1b22fe6eb.json +1 -0
  11. package/.nyc_output/79dc2aeb-d682-45b3-8430-eea8b886e5ae.json +1 -0
  12. package/.nyc_output/processinfo/2807648c-3b13-4cd1-b949-11ce1b846277.json +1 -0
  13. package/.nyc_output/processinfo/48e04c5a-5723-4547-b9d6-20074786acab.json +1 -0
  14. package/.nyc_output/processinfo/51e8de95-1005-492b-8e2f-d7c6fc9148e4.json +1 -0
  15. package/.nyc_output/processinfo/577e3334-ad22-4b05-ac7f-e0038582bb25.json +1 -0
  16. package/.nyc_output/processinfo/59cc8cf4-849a-4cb5-bc52-0133091e0584.json +1 -0
  17. package/.nyc_output/processinfo/5fc28c76-8c92-44e9-9bae-ec2e85892509.json +1 -0
  18. package/.nyc_output/processinfo/5fffbcf8-4572-45c7-948f-38aeb3421a3e.json +1 -0
  19. package/.nyc_output/processinfo/6b02b68b-ad99-40ff-b34f-218d98a9c773.json +1 -0
  20. package/.nyc_output/processinfo/6ec27c2e-3529-412c-a82b-d1b8970a52a5.json +1 -0
  21. package/.nyc_output/processinfo/7540c691-20e7-4eb9-a21e-75f1b22fe6eb.json +1 -0
  22. package/.nyc_output/processinfo/79dc2aeb-d682-45b3-8430-eea8b886e5ae.json +1 -0
  23. package/.nyc_output/processinfo/index.json +1 -0
  24. package/bin/commands/runs.js +17 -6
  25. package/bin/helpers/capabilityHelper.js +24 -24
  26. package/bin/helpers/checkUploaded.js +1 -1
  27. package/bin/helpers/config.js +2 -0
  28. package/bin/helpers/constants.js +17 -4
  29. package/bin/helpers/getInitialDetails.js +3 -0
  30. package/bin/helpers/packageInstaller.js +33 -11
  31. package/bin/helpers/readCypressConfigUtil.js +116 -0
  32. package/bin/helpers/requireModule.js +14 -0
  33. package/bin/helpers/utils.js +85 -9
  34. package/bin/helpers/zipUpload.js +1 -0
  35. package/log/usage.log +11 -0
  36. package/package.json +1 -1
@@ -405,7 +405,7 @@ exports.setRecordKeyFlag = (bsConfig, args) => {
405
405
  return bsConfig.run_settings["record-key"];
406
406
  }
407
407
 
408
- exports.setProjectId = (bsConfig, args) => {
408
+ exports.setProjectId = (bsConfig, args, cypressConfigFile) => {
409
409
  if(!this.isUndefined(args["projectId"])) {
410
410
  return args["projectId"];
411
411
  } else if(!this.isUndefined(process.env.CYPRESS_PROJECT_ID)) {
@@ -413,17 +413,16 @@ exports.setProjectId = (bsConfig, args) => {
413
413
  } else if(!this.isUndefined(bsConfig.run_settings["projectId"])) {
414
414
  return bsConfig.run_settings["projectId"];
415
415
  } else {
416
- let cypressConfigFile = this.getCypressConfigFile(bsConfig);
417
416
  if (!this.isUndefined(cypressConfigFile) && !this.isUndefined(cypressConfigFile["projectId"])) {
418
417
  return cypressConfigFile["projectId"];
419
418
  }
420
419
  }
421
420
  }
422
421
 
423
- exports.setRecordCaps = (bsConfig, args) => {
422
+ exports.setRecordCaps = (bsConfig, args, cypressConfigFile) => {
424
423
  bsConfig.run_settings["record"] = this.setRecordFlag(bsConfig, args);
425
424
  bsConfig.run_settings["record-key"] = this.setRecordKeyFlag(bsConfig, args);
426
- bsConfig.run_settings["projectId"] = this.setProjectId(bsConfig, args);
425
+ bsConfig.run_settings["projectId"] = this.setProjectId(bsConfig, args, cypressConfigFile);
427
426
  }
428
427
 
429
428
  exports.verifyNodeVersionOption = () => {
@@ -987,11 +986,79 @@ exports.getFilesToIgnore = (runSettings, excludeFiles, logging = true) => {
987
986
  }
988
987
 
989
988
  exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig) => {
990
- let testFolderPath = cypressConfig.integrationFolder || Constants.DEFAULT_CYPRESS_SPEC_PATH;
991
- let globSearchPattern = this.sanitizeSpecsPattern(bsConfig.run_settings.specs) || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`;
992
- let ignoreFiles = args.exclude || bsConfig.run_settings.exclude;
993
- let files = glob.sync(globSearchPattern, {cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles});
994
- logger.debug(`${files ? files.length : 0} spec files found at ${testFolderPath}`);
989
+ let defaultSpecFolder
990
+ let testFolderPath
991
+ let globCypressConfigSpecPatterns = []
992
+ let globSearchPattern = this.sanitizeSpecsPattern(bsConfig.run_settings.specs);
993
+ let ignoreFiles = args.exclude || bsConfig.run_settings.exclude
994
+
995
+ if (bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
996
+ defaultSpecFolder = Constants.DEFAULT_CYPRESS_10_SPEC_PATH
997
+ testFolderPath = defaultSpecFolder
998
+ if(!this.isUndefined(cypressConfig) && !this.isUndefined(cypressConfig.e2e)) {
999
+ if(!this.isUndefined(cypressConfig.e2e.specPattern)) {
1000
+ globCypressConfigSpecPatterns = Array.isArray(cypressConfig.e2e.specPattern) ?
1001
+ cypressConfig.e2e.specPattern : [cypressConfig.e2e.specPattern];
1002
+ } else {
1003
+ globCypressConfigSpecPatterns = [`${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`]
1004
+ }
1005
+ } else {
1006
+ // if not able read cypress config
1007
+ // use bstack specs arg(existing logic, which is not correct) if bstack specs arg not provided check for cypress/e2e folder
1008
+ globCypressConfigSpecPatterns = globSearchPattern ? [globSearchPattern] : [`${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`]
1009
+ const filesMatched = [];
1010
+ globCypressConfigSpecPatterns.forEach(specPattern => {
1011
+ filesMatched.push(
1012
+ ...glob.sync(specPattern, {
1013
+ cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles
1014
+ })
1015
+ );
1016
+ });
1017
+ if (!filesMatched.length) {
1018
+ // if no files found under cypress/e2e check for cypress/integration
1019
+ globCypressConfigSpecPatterns = [`${Constants.DEFAULT_CYPRESS_SPEC_PATH}/**/*.+(${Constants.specFileTypes.join("|")})`]
1020
+ }
1021
+ }
1022
+ } else {
1023
+ defaultSpecFolder = Constants.DEFAULT_CYPRESS_SPEC_PATH
1024
+ let testFolderPath = cypressConfig.integrationFolder && cypressConfig.integrationFolder !== '.' ?
1025
+ cypressConfig.integrationFolder : defaultSpecFolder;
1026
+ if(!this.isUndefined(cypressConfig.testFiles)) {
1027
+ if (Array.isArray(cypressConfig.testFiles)) {
1028
+ cypressConfig.testFiles.forEach(specPattern => {
1029
+ globCypressConfigSpecPatterns.push(`${testFolderPath}/${specPattern}`)
1030
+ });
1031
+ } else {
1032
+ globCypressConfigSpecPatterns = [`${testFolderPath}/${cypressConfig.testFiles}`]
1033
+ }
1034
+ } else {
1035
+ globCypressConfigSpecPatterns = [`${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`]
1036
+ }
1037
+ }
1038
+
1039
+ let fileMatchedWithConfigSpecPattern = []
1040
+ globCypressConfigSpecPatterns.forEach(specPattern => {
1041
+ fileMatchedWithConfigSpecPattern.push(
1042
+ ...glob.sync(specPattern, {
1043
+ cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles
1044
+ })
1045
+ );
1046
+ });
1047
+ fileMatchedWithConfigSpecPattern = fileMatchedWithConfigSpecPattern.map((file) => path.resolve(bsConfig.run_settings.cypressProjectDir, file))
1048
+
1049
+ let files
1050
+ if (globSearchPattern) {
1051
+ let fileMatchedWithBstackSpecPattern = glob.sync(globSearchPattern, {
1052
+ cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles
1053
+ });
1054
+ fileMatchedWithBstackSpecPattern = fileMatchedWithBstackSpecPattern.map((file) => path.resolve(bsConfig.run_settings.cypressProjectDir, file))
1055
+
1056
+ files = fileMatchedWithBstackSpecPattern.filter(file => fileMatchedWithConfigSpecPattern.includes(file))
1057
+ } else {
1058
+ files = fileMatchedWithConfigSpecPattern;
1059
+ }
1060
+
1061
+ logger.debug(`${files ? files.length : 0} spec files found`);
995
1062
  return files;
996
1063
  };
997
1064
 
@@ -1045,6 +1112,15 @@ exports.getNetworkErrorMessage = (dashboard_url) => {
1045
1112
  return chalk.red(message)
1046
1113
  }
1047
1114
 
1115
+ exports.setNetworkLogs = (bsConfig) => {
1116
+ if(bsConfig.run_settings.networkLogs == 'true' || bsConfig.run_settings.networkLogs == true) {
1117
+ bsConfig.run_settings.networkLogs = 'true'
1118
+ } else {
1119
+ bsConfig.run_settings.networkLogs = 'false'
1120
+ }
1121
+ logger.debug(`Networks logs value: ${bsConfig.run_settings.networkLogs}`);
1122
+ }
1123
+
1048
1124
  exports.versionChangedMessage = (preferredVersion, actualVersion, frameworkUpgradeMessage = '') => {
1049
1125
  let message = Constants.userMessages.CYPRESS_VERSION_CHANGED.replace("<preferredVersion>", preferredVersion);
1050
1126
  message = message.replace("<actualVersion>", actualVersion);
@@ -28,6 +28,7 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
28
28
  obj.startTime = Date.now();
29
29
 
30
30
  if (opts.urlPresent) {
31
+ opts.cleanupMethod();
31
32
  return resolve({ [opts.md5ReturnKey]: opts.url });
32
33
  }
33
34
  if (!opts.archivePresent) {
package/log/usage.log ADDED
@@ -0,0 +1,11 @@
1
+ {"level":"info","message":"Sending {\"event_type\":\"cypress_cli_stats\",\"data\":{\"bstack_json\":\"{auth: { \\\"username\\\": [REDACTED], \\\"access_key\\\": [REDACTED] },\\\"run_settings\\\":{\\\"cypress_proj_dir\\\":\\\"random path\\\",\\\"cypressConfigFilePath\\\":\\\"random path\\\",\\\"cypressProjectDir\\\":\\\"random path\\\"}}\",\"run_settings\":{\"cypress_proj_dir\":\"random path\",\"cypressConfigFilePath\":\"random path\",\"cypressProjectDir\":\"random path\"},\"os\":\"darwin\",\"os_version\":\"21.6.0\",\"bstack_json_found_in_pwd\":false,\"cypress_config_file_found_in_pwd\":null,\"cli_version\":\"1.19.3\",\"cli_path\":\"/Users/archish/.nvm/versions/node/v12.18.3/lib/node_modules\",\"npm_version\":\"6.14.6\",\"local_cypress_version\":null,\"ci_environment\":null,\"event_timestamp\":\"1/31/2023, 11:40:03\",\"data\":null,\"cli_args\":\"{\\\"_\\\":[\\\"generate-downloads\\\",\\\"f3c94f7203792d03a75be3912d19354fe0961e53\\\"],\\\"cf\\\":\\\"browserstack.json\\\",\\\"config-file\\\":\\\"browserstack.json\\\",\\\"configFile\\\":\\\"browserstack.json\\\",\\\"$0\\\":\\\"browserstack-cypress\\\"}\",\"message_type\":\"error\",\"error_code\":\"get_initial_details_failed\"}} to https://eds.browserstack.com:443/send_event_cy_internal","timestamp":"2023-01-31T06:10:03.266Z"}
2
+ {"level":"info","message":"Sending {\"event_type\":\"cypress_cli_stats\",\"data\":{\"bstack_json\":\"{auth: { \\\"username\\\": [REDACTED], \\\"access_key\\\": [REDACTED] },\\\"run_settings\\\":{\\\"cypress_proj_dir\\\":\\\"random path\\\",\\\"cypressConfigFilePath\\\":\\\"random path\\\",\\\"cypressProjectDir\\\":\\\"random path\\\"}}\",\"run_settings\":{\"cypress_proj_dir\":\"random path\",\"cypressConfigFilePath\":\"random path\",\"cypressProjectDir\":\"random path\"},\"os\":\"darwin\",\"os_version\":\"21.6.0\",\"bstack_json_found_in_pwd\":false,\"cypress_config_file_found_in_pwd\":null,\"cli_version\":\"1.19.3\",\"cli_path\":\"/Users/archish/.nvm/versions/node/v12.18.3/lib/node_modules\",\"npm_version\":\"6.14.6\",\"local_cypress_version\":null,\"ci_environment\":null,\"event_timestamp\":\"1/31/2023, 11:40:04\",\"data\":null,\"cli_args\":\"{\\\"_\\\":[\\\"generate-report\\\",\\\"f3c94f7203792d03a75be3912d19354fe0961e53\\\"],\\\"cf\\\":\\\"browserstack.json\\\",\\\"config-file\\\":\\\"browserstack.json\\\",\\\"configFile\\\":\\\"browserstack.json\\\",\\\"$0\\\":\\\"browserstack-cypress\\\"}\",\"message_type\":\"error\",\"error_code\":\"get_initial_details_failed\"}} to https://eds.browserstack.com:443/send_event_cy_internal","timestamp":"2023-01-31T06:10:04.595Z"}
3
+ {"level":"info","message":"{\"attempts\":1,\"statusCode\":200,\"body\":\"Bravo\"}","timestamp":"2023-01-31T06:10:05.953Z"}
4
+ {"level":"info","message":"{\"attempts\":2,\"statusCode\":200,\"body\":\"Bravo\"}","timestamp":"2023-01-31T06:10:08.704Z"}
5
+ {"level":"info","message":"Sending {\"event_type\":\"cypress_cli_stats\",\"data\":{\"bstack_json\":\"{auth: { \\\"username\\\": [REDACTED], \\\"access_key\\\": [REDACTED] },\\\"run_settings\\\":{\\\"cypress_proj_dir\\\":\\\"random path\\\",\\\"cypressConfigFilePath\\\":\\\"random path\\\",\\\"cypressProjectDir\\\":\\\"random path\\\"}}\",\"run_settings\":{\"cypress_proj_dir\":\"random path\",\"cypressConfigFilePath\":\"random path\",\"cypressProjectDir\":\"random path\"},\"os\":\"darwin\",\"os_version\":\"21.6.0\",\"bstack_json_found_in_pwd\":false,\"cypress_config_file_found_in_pwd\":null,\"cli_version\":\"1.19.3\",\"cli_path\":\"/Users/archish/.nvm/versions/node/v12.18.3/lib/node_modules\",\"npm_version\":\"6.14.6\",\"local_cypress_version\":null,\"ci_environment\":null,\"event_timestamp\":\"1/31/2023, 11:45:33\",\"data\":null,\"cli_args\":\"{\\\"_\\\":[\\\"generate-downloads\\\",\\\"f3c94f7203792d03a75be3912d19354fe0961e53\\\"],\\\"cf\\\":\\\"browserstack.json\\\",\\\"config-file\\\":\\\"browserstack.json\\\",\\\"configFile\\\":\\\"browserstack.json\\\",\\\"$0\\\":\\\"browserstack-cypress\\\"}\",\"message_type\":\"error\",\"error_code\":\"get_initial_details_failed\"}} to https://eds.browserstack.com:443/send_event_cy_internal","timestamp":"2023-01-31T06:15:33.253Z"}
6
+ {"level":"info","message":"Sending {\"event_type\":\"cypress_cli_stats\",\"data\":{\"bstack_json\":\"{auth: { \\\"username\\\": [REDACTED], \\\"access_key\\\": [REDACTED] },\\\"run_settings\\\":{\\\"cypress_proj_dir\\\":\\\"random path\\\",\\\"cypressConfigFilePath\\\":\\\"random path\\\",\\\"cypressProjectDir\\\":\\\"random path\\\"}}\",\"run_settings\":{\"cypress_proj_dir\":\"random path\",\"cypressConfigFilePath\":\"random path\",\"cypressProjectDir\":\"random path\"},\"os\":\"darwin\",\"os_version\":\"21.6.0\",\"bstack_json_found_in_pwd\":false,\"cypress_config_file_found_in_pwd\":null,\"cli_version\":\"1.19.3\",\"cli_path\":\"/Users/archish/.nvm/versions/node/v12.18.3/lib/node_modules\",\"npm_version\":\"6.14.6\",\"local_cypress_version\":null,\"ci_environment\":null,\"event_timestamp\":\"1/31/2023, 11:45:34\",\"data\":null,\"cli_args\":\"{\\\"_\\\":[\\\"generate-report\\\",\\\"f3c94f7203792d03a75be3912d19354fe0961e53\\\"],\\\"cf\\\":\\\"browserstack.json\\\",\\\"config-file\\\":\\\"browserstack.json\\\",\\\"configFile\\\":\\\"browserstack.json\\\",\\\"$0\\\":\\\"browserstack-cypress\\\"}\",\"message_type\":\"error\",\"error_code\":\"get_initial_details_failed\"}} to https://eds.browserstack.com:443/send_event_cy_internal","timestamp":"2023-01-31T06:15:34.443Z"}
7
+ {"level":"info","message":"{\"attempts\":1,\"statusCode\":200,\"body\":\"Bravo\"}","timestamp":"2023-01-31T06:15:35.939Z"}
8
+ {"level":"info","message":"{\"attempts\":2,\"statusCode\":200,\"body\":\"Bravo\"}","timestamp":"2023-01-31T06:15:38.839Z"}
9
+ {"level":"info","message":"Sending {\"event_type\":\"cypress_cli_stats\",\"data\":{\"bstack_json\":\"{auth: { \\\"username\\\": [REDACTED], \\\"access_key\\\": [REDACTED] },\\\"run_settings\\\":{\\\"cypress_proj_dir\\\":\\\"random path\\\",\\\"cypressConfigFilePath\\\":\\\"random path\\\",\\\"cypressProjectDir\\\":\\\"random path\\\"}}\",\"run_settings\":{\"cypress_proj_dir\":\"random path\",\"cypressConfigFilePath\":\"random path\",\"cypressProjectDir\":\"random path\"},\"os\":\"darwin\",\"os_version\":\"21.6.0\",\"bstack_json_found_in_pwd\":false,\"cypress_config_file_found_in_pwd\":null,\"cli_version\":\"1.19.3\",\"cli_path\":\"/Users/archish/.nvm/versions/node/v12.18.3/lib/node_modules\",\"npm_version\":\"6.14.6\",\"local_cypress_version\":null,\"ci_environment\":null,\"event_timestamp\":\"2/9/2023, 12:03:13\",\"data\":null,\"cli_args\":\"{\\\"_\\\":[\\\"generate-downloads\\\",\\\"f3c94f7203792d03a75be3912d19354fe0961e53\\\"],\\\"cf\\\":\\\"browserstack.json\\\",\\\"config-file\\\":\\\"browserstack.json\\\",\\\"configFile\\\":\\\"browserstack.json\\\",\\\"$0\\\":\\\"browserstack-cypress\\\"}\",\"message_type\":\"error\",\"error_code\":\"get_initial_details_failed\"}} to https://eds.browserstack.com:443/send_event_cy_internal","timestamp":"2023-02-09T06:33:13.370Z"}
10
+ {"level":"info","message":"Sending {\"event_type\":\"cypress_cli_stats\",\"data\":{\"bstack_json\":\"{auth: { \\\"username\\\": [REDACTED], \\\"access_key\\\": [REDACTED] },\\\"run_settings\\\":{\\\"cypress_proj_dir\\\":\\\"random path\\\",\\\"cypressConfigFilePath\\\":\\\"random path\\\",\\\"cypressProjectDir\\\":\\\"random path\\\"}}\",\"run_settings\":{\"cypress_proj_dir\":\"random path\",\"cypressConfigFilePath\":\"random path\",\"cypressProjectDir\":\"random path\"},\"os\":\"darwin\",\"os_version\":\"21.6.0\",\"bstack_json_found_in_pwd\":false,\"cypress_config_file_found_in_pwd\":null,\"cli_version\":\"1.19.3\",\"cli_path\":\"/Users/archish/.nvm/versions/node/v12.18.3/lib/node_modules\",\"npm_version\":\"6.14.6\",\"local_cypress_version\":null,\"ci_environment\":null,\"event_timestamp\":\"2/9/2023, 12:03:14\",\"data\":null,\"cli_args\":\"{\\\"_\\\":[\\\"generate-report\\\",\\\"f3c94f7203792d03a75be3912d19354fe0961e53\\\"],\\\"cf\\\":\\\"browserstack.json\\\",\\\"config-file\\\":\\\"browserstack.json\\\",\\\"configFile\\\":\\\"browserstack.json\\\",\\\"$0\\\":\\\"browserstack-cypress\\\"}\",\"message_type\":\"error\",\"error_code\":\"get_initial_details_failed\"}} to https://eds.browserstack.com:443/send_event_cy_internal","timestamp":"2023-02-09T06:33:14.206Z"}
11
+ {"level":"info","message":"{\"attempts\":1,\"statusCode\":200,\"body\":\"Bravo\"}","timestamp":"2023-02-09T06:33:15.228Z"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.21.0",
3
+ "version": "1.22.1",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {