browserstack-cypress-cli 1.13.0 → 1.14.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.
@@ -7,7 +7,8 @@ const crypto = require('crypto'),
7
7
  config = require('./config'),
8
8
  path = require('path'),
9
9
  fs = require("fs"),
10
- utils = require('./utils');
10
+ utils = require('./utils'),
11
+ logger = require('./logger').winstonLogger;
11
12
 
12
13
 
13
14
  const checkSpecsMd5 = (runSettings, args, instrumentBlocks) => {
@@ -83,6 +84,7 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
83
84
  packageUrlPresent: false,
84
85
  };
85
86
  if (args["force-upload"]) {
87
+ logger.debug("force-upload set to true. Uploading tests and npm packages.");
86
88
  return resolve(obj);
87
89
  }
88
90
 
@@ -16,6 +16,7 @@ config.cypress_v1 = `${config.rails_host}/automate/cypress/v1`;
16
16
  config.buildUrl = `${config.cypress_v1}/builds/`;
17
17
  config.buildStopUrl = `${config.cypress_v1}/builds/stop/`;
18
18
  config.checkMd5sum = `${config.cypress_v1}/md5sumcheck/`;
19
+ config.getInitialDetails = `${config.cypress_v1}/get_initial_details/`;
19
20
  config.fileName = "tests.zip";
20
21
  config.packageFileName = "bstackPackages.tar.gz";
21
22
  config.packageDirName = "tmpBstackPackages";
@@ -21,6 +21,7 @@ const userMessages = {
21
21
  ZIP_UPLOADER_NOT_REACHABLE: "Could not reach BrowserStack APIs. Please check your network or see if you need to whitelist *.browserstack.com",
22
22
  ZIP_UPLOAD_FAILED: "Zip Upload failed.",
23
23
  ZIP_UPLOAD_LIMIT_EXCEEDED: "The directory size which contains the cypress config file is more than 200 MB. For more info, check out https://www.browserstack.com/docs/automate/cypress/exclude-files",
24
+ NODE_MODULES_LIMIT_EXCEEDED: "node_modules upload failed as the size %SIZE% MB is not supported. Dependencies will be installed in runtime. This will have a negative impact on build performance. Reach out to us at browserstack.com/support if you see this warning.",
24
25
  CONFIG_FILE_CREATED: "BrowserStack Config File created, you can now run browserstack-cypress --config-file run",
25
26
  CONFIG_FILE_EXISTS: "File already exists, delete the browserstack.json file manually. skipping...",
26
27
  DIR_NOT_FOUND: "Given path does not exist. Failed to create browserstack.json in %s",
@@ -101,7 +102,9 @@ const validationMessages = {
101
102
  HOME_DIRECTORY_NOT_A_DIRECTORY: "Specified home directory is not a directory. The home directory can only be a directory and not a file.",
102
103
  CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY: "Could not find cypress.json within the specified home directory. Please make sure cypress.json resides within the home directory.",
103
104
  SPEC_TIMEOUT_LIMIT_ERROR: "The maximum allowed value of 'spec_timeout' is 120. Read more on https://browserstack.com/docs/automate/cypress/spec-timeout ",
104
- SPEC_TIMEOUT_NOT_PASSED_ERROR: "'spec_timeout' key not specified. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout "
105
+ SPEC_TIMEOUT_NOT_PASSED_ERROR: "'spec_timeout' key not specified. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout ",
106
+ PROJECT_ID_MISSING: "You have specified '--record' flag but you've not provided the 'projectId' in cypress.json or in browserstack.json. Your record functionality on cypress.io dashboard might not work as it needs both the key and the projectId",
107
+ RECORD_KEY_MISSING: "You have specified '--record' flag but you've not provided the '--record-key' and we could not find any value in 'CYPRESS_RECORD_KEY' environment variable. Your record functionality on cypress.io dashboard might not work as it needs the key and projectId"
105
108
  };
106
109
 
107
110
  const cliMessages = {
@@ -145,7 +148,10 @@ const cliMessages = {
145
148
  REPORTER: "Specify the custom reporter to use",
146
149
  REPORTER_OPTIONS: "Specify reporter options for custom reporter",
147
150
  CYPRESS_GEO_LOCATION: "Enterprise feature to simulate website and mobile behavior from different locations.",
148
- SPEC_TIMEOUT: "Specify a value for a hard timeout for each spec execution in the 1-120 mins range. Read https://browserstack.com/docs/automate/cypress/spec-timeout for more details."
151
+ SPEC_TIMEOUT: "Specify a value for a hard timeout for each spec execution in the 1-120 mins range. Read https://browserstack.com/docs/automate/cypress/spec-timeout for more details.",
152
+ RECORD: "Pass the --record flag to record your Cypress runs on Cypress.io dashboard. Note: You also need to specify '--record-key' and '--projectId' arguments either in CLI or in browserstack.json.",
153
+ RECORD_KEY: "You can specify the 'key' that is needed to record your runs on Cypress.io dashboard using the '--record-key' argument. Alternatively, you can also pass it on browserstack.json",
154
+ PROJECT_ID: "You can pass the 'projectId' of your Cypress.io project where you want to record your runs if specifying the '--record' key. You can also specify this in your cypress.json or in your browserstack.json."
149
155
  },
150
156
  COMMON: {
151
157
  DISABLE_USAGE_REPORTING: "Disable usage reporting",
@@ -155,6 +161,7 @@ const cliMessages = {
155
161
  NO_NPM_WARNING: "No NPM warning if npm_dependencies is empty",
156
162
  CONFIG_DEMAND: "config file is required",
157
163
  CONFIG_FILE_PATH: "Path to BrowserStack config",
164
+ DEBUG: "Use this option to get debug logs on the CLI console.",
158
165
  },
159
166
  GENERATE_REPORT: {
160
167
  INFO: "Generates the build report"
@@ -231,6 +238,10 @@ const LATEST_VERSION_SYNTAX_REGEX = /\d*.latest(.\d*)?/gm
231
238
 
232
239
  const AUTH_REGEX = /"auth" *: *{[\s\S]*?}/g
233
240
 
241
+ const CLI_ARGS_REGEX = /(?<=("u"|"username"|"k"|"key") *: *)"[^,}]*/g
242
+
243
+ const RAW_ARGS_REGEX = /(?<=("-u"|"-username"|"-k"|"-key") *, *)"[^,\]]*/g
244
+
234
245
  const ERROR_EXIT_CODE = 1;
235
246
 
236
247
  const BUILD_FAILED_EXIT_CODE = 3;
@@ -241,6 +252,8 @@ const REDACTED_AUTH =`auth: { "username": ${REDACTED}, "access_key": ${REDACTED}
241
252
 
242
253
  const SPEC_TIMEOUT_LIMIT = 120 // IN MINS
243
254
 
255
+ const CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY = "custom_errors_to_print";
256
+
244
257
  module.exports = Object.freeze({
245
258
  syncCLI,
246
259
  userMessages,
@@ -260,7 +273,11 @@ module.exports = Object.freeze({
260
273
  LATEST_VERSION_SYNTAX_REGEX,
261
274
  ERROR_EXIT_CODE,
262
275
  AUTH_REGEX,
276
+ CLI_ARGS_REGEX,
277
+ RAW_ARGS_REGEX,
263
278
  REDACTED_AUTH,
279
+ REDACTED,
264
280
  BUILD_FAILED_EXIT_CODE,
265
- SPEC_TIMEOUT_LIMIT
281
+ SPEC_TIMEOUT_LIMIT,
282
+ CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY
266
283
  });
@@ -45,6 +45,7 @@ exports.deletePackageArchieve = (logging = true) => {
45
45
  return 0;
46
46
  } catch (err) {
47
47
  if (logging) logger.info(Constants.userMessages.NPM_DELETE_FAILED);
48
+ logger.debug("Could not delete the dependency packages with error :", err);
48
49
  return 1;
49
50
  }
50
51
  };
@@ -0,0 +1,41 @@
1
+ const request = require('request'),
2
+ logger = require('./logger').winstonLogger,
3
+ utils = require('./utils'),
4
+ config = require("./config"),
5
+ Constants = require('./constants');
6
+
7
+ exports.getInitialDetails = (bsConfig, args, rawArgs) => {
8
+ return new Promise((resolve, reject) => {
9
+ let options = {
10
+ url: config.getInitialDetails,
11
+ auth: {
12
+ username: bsConfig.auth.username,
13
+ password: bsConfig.auth.access_key,
14
+ },
15
+ headers: {
16
+ 'User-Agent': utils.getUserAgent(),
17
+ }
18
+ };
19
+ let responseData = {};
20
+ request.get(options, function (err, resp, data) {
21
+ if(err) {
22
+ logger.warn(utils.formatRequest(err, resp, data));
23
+ utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'get_initial_details_failed', null, rawArgs);
24
+ resolve({});
25
+ } else {
26
+ try {
27
+ responseData = JSON.parse(data);
28
+ } catch (e) {
29
+ responseData = {};
30
+ }
31
+ if(resp.statusCode != 200) {
32
+ logger.warn(`Warn: Get Initial Details Request failed with status code ${resp.statusCode}`);
33
+ utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'get_initial_details_failed', null, rawArgs);
34
+ resolve({});
35
+ } else {
36
+ resolve(responseData);
37
+ }
38
+ }
39
+ });
40
+ });
41
+ };
@@ -8,37 +8,47 @@ if (!fs.existsSync(logDir)) {
8
8
  fs.mkdirSync(logDir);
9
9
  }
10
10
 
11
+ // Save transports to change log level dynamically
12
+ const transports = {
13
+ loggerConsole: new winston.transports.Console({
14
+ name: 'console.info',
15
+ colorize: true,
16
+ timestamp: function () {
17
+ return `[${new Date().toLocaleString()}]`;
18
+ },
19
+ prettyPrint: true,
20
+ }),
21
+ syncLoggerConsole: new (winston.transports.Console)({
22
+ formatter: (options) => {
23
+ return (options.message ? options.message : '');
24
+ }
25
+ }),
26
+ loggerFile: new winston.transports.File({
27
+ filename: path.join(logDir, "/usage.log"),
28
+ }),
29
+ }
30
+
11
31
  const winstonLoggerParams = {
12
32
  transports: [
13
- new winston.transports.Console({
14
- name: 'console.info',
15
- colorize: true,
16
- timestamp: function () {
17
- return `[${new Date().toLocaleString()}]`;
18
- },
19
- prettyPrint: true,
20
- }),
33
+ transports.loggerConsole,
21
34
  ],
22
35
  };
23
36
 
24
37
  const winstonSyncCliLoggerParams = {
25
38
  transports: [
26
- new (winston.transports.Console)({
27
- formatter: (options) => {
28
- return (options.message ? options.message : '');
29
- }
30
- }),
39
+ transports.syncLoggerConsole,
31
40
  ]
32
41
  }
33
42
 
34
43
  const winstonFileLoggerParams = {
35
44
  transports: [
36
- new winston.transports.File({
37
- filename: path.join(logDir, "/usage.log"),
38
- }),
45
+ transports.loggerFile,
39
46
  ],
40
47
  };
41
48
 
42
49
  exports.winstonLogger = new winston.Logger(winstonLoggerParams);
43
50
  exports.fileLogger = new winston.Logger(winstonFileLoggerParams);
44
51
  exports.syncCliLogger = new winston.Logger(winstonSyncCliLoggerParams);
52
+
53
+ //Export transports to change log level
54
+ exports.transports = transports;
@@ -7,18 +7,21 @@
7
7
  Constants = require('./constants'),
8
8
  process = require('process'),
9
9
  utils = require('./utils'),
10
- { spawn } = require('child_process');
10
+ { spawn } = require('child_process'),
11
+ util = require('util');
11
12
 
12
13
  let nodeProcess;
13
14
 
14
15
  const setupPackageFolder = (runSettings, directoryPath) => {
15
16
  return new Promise(function (resolve, reject) {
16
17
  fileHelpers.deletePackageArchieve(false);
18
+ logger.debug(`Started creating ${directoryPath} folder`);
17
19
  fs.mkdir(directoryPath, function (err) {
18
20
  try {
19
21
  if (err) {
20
22
  return reject(err);
21
23
  }
24
+ logger.debug(`Completed creating ${directoryPath}`);
22
25
  let packageJSON = {};
23
26
  if (typeof runSettings.package_config_options === 'object') {
24
27
  Object.assign(packageJSON, runSettings.package_config_options);
@@ -38,12 +41,16 @@ const setupPackageFolder = (runSettings, directoryPath) => {
38
41
  let sourceNpmrc = path.join(cypressFolderPath, ".npmrc");
39
42
  let destNpmrc = path.join(directoryPath, ".npmrc");
40
43
  if (fs.existsSync(sourceNpmrc)) {
44
+ logger.debug(`Copying .npmrc file from ${sourceNpmrc} to ${destNpmrc}`);
41
45
  fs.copyFileSync(sourceNpmrc, destNpmrc);
42
46
  }
47
+ logger.debug(`${packagePath} file created with ${packageJSONString}`);
43
48
  return resolve("Package file created");
44
49
  }
50
+ logger.debug("Nothing in package file");
45
51
  return reject("Nothing in package file");
46
52
  } catch(error) {
53
+ logger.debug(`Creating ${directoryPath} failed with error ${error}`);
47
54
  return reject(error);
48
55
  }
49
56
  })
@@ -54,16 +61,18 @@ const packageInstall = (packageDir) => {
54
61
  return new Promise(function (resolve, reject) {
55
62
  const nodeProcessCloseCallback = (code) => {
56
63
  if(code == 0) {
64
+ logger.info(`Packages were installed locally successfully.`);
57
65
  resolve('Packages were installed successfully.');
58
66
  } else {
59
- reject('Packages were not installed successfully.');
67
+ logger.error(`Some error occurred while installing packages. Error code ${code}`);
68
+ reject(`Packages were not installed successfully. Error code ${code}`);
60
69
  }
61
70
  };
62
71
  const nodeProcessErrorCallback = (error) => {
63
- logger.error(`Some error occurred while installing packages: ${error}`);
64
- reject(`Packages were not installed successfully.`);
72
+ logger.error(`Some error occurred while installing packages: %j`, error);
73
+ reject(`Packages were not installed successfully. Error Description ${util.format('%j', error)}`);
65
74
  };
66
- nodeProcess = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install'], {cwd: packageDir});
75
+ nodeProcess = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install', '--loglevel', 'verbose', '>', '../npm_install_debug.log', '2>&1'], {cwd: packageDir, shell: true});
67
76
  nodeProcess.on('close', nodeProcessCloseCallback);
68
77
  nodeProcess.on('error', nodeProcessErrorCallback);
69
78
  });
@@ -79,6 +88,7 @@ const packageArchiver = (packageDir, packageFile) => {
79
88
  if (err.code === 'ENOENT') {
80
89
  logger.info(err);
81
90
  } else {
91
+ logger.debug(`Archiving of node_modules failed with error ${err}`);
82
92
  reject(err);
83
93
  }
84
94
  });
@@ -92,6 +102,7 @@ const packageArchiver = (packageDir, packageFile) => {
92
102
  });
93
103
 
94
104
  archive.on('error', function (err) {
105
+ logger.debug(`Archiving of node_modules failed with error ${err}`);
95
106
  reject(err);
96
107
  });
97
108
 
@@ -107,24 +118,32 @@ const packageWrapper = (bsConfig, packageDir, packageFile, md5data, instrumentBl
107
118
  packageArchieveCreated: false
108
119
  };
109
120
  if (md5data.packageUrlPresent || !utils.isTrueString(bsConfig.run_settings.cache_dependencies)) {
121
+ logger.debug("Skipping the caching of npm packages since BrowserStack has already cached your npm dependencies that have not changed since the last run.")
110
122
  return resolve(obj);
111
123
  }
112
124
  logger.info(Constants.userMessages.NPM_INSTALL_AND_UPLOAD);
113
125
  instrumentBlocks.markBlockStart("packageInstaller.folderSetup");
126
+ logger.debug("Started setting up package folder");
114
127
  return setupPackageFolder(bsConfig.run_settings, packageDir).then((_result) => {
128
+ logger.debug("Completed setting up package folder");
115
129
  process.env.CYPRESS_INSTALL_BINARY = 0
116
130
  instrumentBlocks.markBlockEnd("packageInstaller.folderSetup");
117
131
  instrumentBlocks.markBlockStart("packageInstaller.packageInstall");
132
+ logger.debug("Started installing dependencies specified in browserstack.json");
118
133
  return packageInstall(packageDir);
119
134
  }).then((_result) => {
135
+ logger.debug("Completed installing dependencies");
120
136
  instrumentBlocks.markBlockEnd("packageInstaller.packageInstall");
121
137
  instrumentBlocks.markBlockStart("packageInstaller.packageArchive");
138
+ logger.debug("Started archiving node_modules")
122
139
  return packageArchiver(packageDir, packageFile);
123
140
  }).then((_result) => {
141
+ logger.debug("Archiving of node_modules completed");
124
142
  instrumentBlocks.markBlockEnd("packageInstaller.packageArchive");
125
143
  Object.assign(obj, { packageArchieveCreated: true });
126
144
  return resolve(obj);
127
145
  }).catch((err) => {
146
+ logger.warn(`Error occured while caching npm dependencies. Dependencies will be installed in runtime. This will have a negative impact on performance. Reach out to browserstack.com/contact, if you persistantly face this issue.`);
128
147
  obj.error = err.stack ? err.stack.toString().substring(0,100) : err.toString().substring(0,100);
129
148
  return resolve(obj);
130
149
  })
@@ -88,7 +88,7 @@ function buildSpecStats(specMeta) {
88
88
  return specStats;
89
89
  }
90
90
 
91
- let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
91
+ let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) => {
92
92
  let options = {
93
93
  url: `${config.buildUrl}${buildId}/custom_report`,
94
94
  auth: {
@@ -114,7 +114,7 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
114
114
  logger.error('Generating the build report failed.');
115
115
  logger.error(utils.formatRequest(err, resp, body));
116
116
 
117
- utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
117
+ utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
118
118
  return;
119
119
  } else {
120
120
  try {
@@ -166,7 +166,7 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
166
166
  await renderReportHTML(build);
167
167
  logger.info(message);
168
168
  }
169
- utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
169
+ utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
170
170
  if (cb){
171
171
  cb();
172
172
  }
@@ -38,10 +38,7 @@ let failedSpecsDetails = (data) => {
38
38
  if (spec.status && spec.status.toLowerCase() === 'failed' && !failedSpecs)
39
39
  failedSpecs = true;
40
40
 
41
- let specStatus =
42
- spec.status && spec.status.toLowerCase() === 'failed'
43
- ? chalk.red(spec.status)
44
- : chalk.yellow(spec.status);
41
+ let specStatus = getSpecStatus(spec.status)
45
42
  specData.push([
46
43
  spec.specName,
47
44
  specStatus,
@@ -79,4 +76,15 @@ let failedSpecsDetails = (data) => {
79
76
  });
80
77
  }
81
78
 
79
+ let getSpecStatus = (specStatus) => {
80
+ switch(specStatus.toLowerCase()) {
81
+ case 'failed': return chalk.red(specStatus);
82
+ case 'pending':
83
+ case 'skipped':
84
+ case 'passed_with_skipped': return chalk.blueBright(specStatus);
85
+ default: return chalk.yellow(specStatus);
86
+ }
87
+ }
88
+
82
89
  exports.failedSpecsDetails = failedSpecsDetails;
90
+ exports.getSpecStatus = getSpecStatus;
@@ -1,4 +1,5 @@
1
1
  const logger = require("../logger").syncCliLogger;
2
+ const winstonlogger = require("../logger").winstonLogger;
2
3
 
3
4
  /**
4
5
  *
@@ -16,22 +17,39 @@ const logger = require("../logger").syncCliLogger;
16
17
  // {specName: 'spec8.alias.js', status: 'Skipped', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'}
17
18
  // ]
18
19
  //
19
- let printSpecsRunSummary = (data, machines) => {
20
+ let printSpecsRunSummary = (data, machines, customErrorsToPrint) => {
20
21
  return new Promise((resolve, _reject) => {
21
22
  let summary = {
22
23
  total: 0,
23
24
  failed: 0,
24
25
  passed: 0,
25
- skipped: 0
26
+ skipped: 0,
27
+ passed_with_skipped: 0,
28
+ pending: 0
26
29
  };
27
30
 
28
31
  data.specs.forEach((spec) => {
29
32
  specSummaryCount(summary, spec.status.toLowerCase());
30
33
  });
31
34
 
32
- logger.info(`Total tests: ${summary.total}, passed: ${summary.passed}, failed: ${summary.failed}, skipped: ${summary.skipped}`);
35
+ logger.info(`Total tests: ${summary.total}, passed: ${summary.passed}, failed: ${summary.failed}, skipped: ${summary.skipped}, passed_with_skipped: ${summary.passed_with_skipped}, pending: ${summary.pending}`);
33
36
  logger.info(`Done in ${data.duration/1000} seconds using ${machines} machines\n`);
34
37
 
38
+ if (customErrorsToPrint && customErrorsToPrint.length > 0) {
39
+ for (const error of customErrorsToPrint) {
40
+ switch(error.level) {
41
+ case 'info':
42
+ winstonlogger.info(error.message);
43
+ break;
44
+ case 'error':
45
+ winstonlogger.error(error.message);
46
+ break;
47
+ default:
48
+ winstonlogger.warn(error.message);
49
+ }
50
+ }
51
+ }
52
+
35
53
  resolve(data.exitCode);
36
54
  })
37
55
  };
@@ -41,9 +59,15 @@ let specSummaryCount = (summary, status) => {
41
59
  case 'failed':
42
60
  summary.failed++;
43
61
  break;
62
+ case "passed_with_skipped":
63
+ summary.passed_with_skipped++;
64
+ break;
44
65
  case 'skipped':
45
66
  summary.skipped++;
46
67
  break;
68
+ case "pending":
69
+ summary.pending++;
70
+ break;
47
71
  case 'passed':
48
72
  summary.passed++;
49
73
  break;
@@ -13,8 +13,10 @@ let whileLoop = true, whileTries = config.retries, options, timeout = 3000, n =
13
13
  let specSummary = {
14
14
  "buildError": null,
15
15
  "specs": [],
16
- "duration": null
16
+ "duration": null,
17
+ "customErrorsToPrint": []
17
18
  }
19
+
18
20
  let noWrap = false;
19
21
  let terminalWidth = (process.stdout.columns) * 0.9;
20
22
  let lineSeparator = Constants.syncCLI.DEFAULT_LINE_SEP;
@@ -87,11 +89,14 @@ let setNoWrapParams = () => {
87
89
  noWrap = (process.env.SYNC_NO_WRAP && (process.env.SYNC_NO_WRAP === 'true'));
88
90
  // Do not show the separator based on terminal width if no-wrap provided.
89
91
  if (noWrap) {
92
+ winstonLogger.debug("no-wrap is set to true, showing the default line separator irrespective of terminal width");
90
93
  lineSeparator = Constants.syncCLI.DEFAULT_LINE_SEP;
94
+ } else {
95
+ winstonLogger.debug("no-wrap set to false, showing line separator based on terminal width.");
91
96
  }
92
97
  };
93
98
 
94
- let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
99
+ let printSpecsStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
95
100
  setNoWrapParams();
96
101
  return new Promise((resolve, reject) => {
97
102
  options = getOptions(bsConfig.auth, buildDetails.build_id)
@@ -107,10 +112,11 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
107
112
  },
108
113
  function(err, result) { // when loop ends
109
114
  if (err) {
115
+ winstonLogger.debug(`Error while fetching spec status :`, err);
110
116
  if(err.status == 204) {
111
117
  reject(specSummary.exitCode);
112
118
  } else {
113
- utils.sendUsageReport(bsConfig, {}, `buildId: ${buildDetails.build_id}`, 'error', 'sync_cli_error', err, rawArgs);
119
+ utils.sendUsageReport(bsConfig, {}, `buildId: ${buildDetails.build_id}`, 'error', 'sync_cli_error', { ...err , ...buildReportData}, rawArgs);
114
120
  }
115
121
  }
116
122
  logger.info(lineSeparator);
@@ -166,18 +172,22 @@ let getStackTraceUrl = () => {
166
172
  let showSpecsStatus = (data) => {
167
173
  let specData = JSON.parse(data);
168
174
  specData.forEach(specDetails => {
169
- if (specDetails == "created") {
170
- return;
171
- } else if (specDetails["stacktrace_url"]) {
172
- specSummary.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
173
- specSummary.buildError = specDetails["stacktrace_url"]
174
- winstonLogger.error(chalk.red(specDetails["message"]));
175
+ if (specDetails.type === Constants.CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY) {
176
+ addCustomErrorToPrint(specDetails);
175
177
  } else {
176
- if(!buildStarted) {
177
- buildStarted = true
178
- printInitialLog();
178
+ if (specDetails == "created") {
179
+ return;
180
+ } else if (specDetails["stacktrace_url"]) {
181
+ specSummary.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
182
+ specSummary.buildError = specDetails["stacktrace_url"]
183
+ winstonLogger.error(chalk.red(specDetails["message"]));
184
+ } else {
185
+ if(!buildStarted) {
186
+ buildStarted = true
187
+ printInitialLog();
188
+ }
189
+ printSpecData(JSON.parse(specDetails));
179
190
  }
180
- printSpecData(JSON.parse(specDetails));
181
191
  }
182
192
  });
183
193
  }
@@ -191,13 +201,25 @@ let printInitialLog = () => {
191
201
 
192
202
  let printSpecData = (data) => {
193
203
  let combination = getCombinationName(data["spec"]);
194
- let status = getStatus(data["spec"]["status"]);
195
- writeToTable(combination, data["path"], status)
196
- addSpecToSummary(data["path"], data["spec"]["status"], combination, data["session_id"])
204
+ let status = data["spec"]["status"];
205
+ let statusMark = getStatus(status);
206
+ writeToTable(combination, data["path"], status, statusMark)
207
+ addSpecToSummary(data["path"], status, combination, data["session_id"])
208
+ }
209
+
210
+ let writeToTable = (combination, specName, status, statusMark) => {
211
+ stream.write([combination , ":", `${specName} ${statusMark} [${status}]`]);
197
212
  }
198
213
 
199
- let writeToTable = (combination, specName, status) => {
200
- stream.write([combination , ":", `${specName} ${status}`]);
214
+ let addCustomErrorToPrint = (error_object) => {
215
+ if (error_object["should_be_unique"]) {
216
+ for (const error of specSummary.customErrorsToPrint) {
217
+ if (error.id === error_object.id) {
218
+ return;
219
+ }
220
+ }
221
+ }
222
+ specSummary.customErrorsToPrint.push(error_object);
201
223
  }
202
224
 
203
225
  let addSpecToSummary = (specName, status, combination, session_id) => {
@@ -220,6 +242,8 @@ let getStatus = (status) => {
220
242
  return chalk.green("✔");
221
243
  case "failed":
222
244
  return chalk.red("✘");
245
+ case "passed_with_skipped":
246
+ return chalk.blueBright("✔");
223
247
  default:
224
248
  return chalk.blue(`[${status}]`);
225
249
  }
@@ -3,12 +3,16 @@ const syncSpecsLogs = require('./sync/syncSpecsLogs'),
3
3
  specDetails = require('./sync/failedSpecsDetails'),
4
4
  specsSummary = require('./sync/specsSummary');
5
5
 
6
- exports.pollBuildStatus = (bsConfig, buildDetails) => {
6
+ exports.pollBuildStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
7
+ let customErrorsToPrint;
7
8
  return new Promise((resolve, reject) => {
8
- syncSpecsLogs.printSpecsStatus(bsConfig, buildDetails).then((data) => {
9
+ syncSpecsLogs.printSpecsStatus(bsConfig, buildDetails, rawArgs, buildReportData).then((data) => {
10
+ if(data.customErrorsToPrint && data.customErrorsToPrint.length > 0) {
11
+ customErrorsToPrint = data.customErrorsToPrint;
12
+ }
9
13
  return specDetails.failedSpecsDetails(data);
10
14
  }).then((data) => {
11
- return specsSummary.printSpecsRunSummary(data, buildDetails.machines);
15
+ return specsSummary.printSpecsRunSummary(data, buildDetails.machines, customErrorsToPrint);
12
16
  }).then((successExitCode) => {
13
17
  resolve(successExitCode); // exit code 0
14
18
  }).catch((nonZeroExitCode) => {
@@ -8,8 +8,8 @@ const cp = require("child_process"),
8
8
  const config = require('./config'),
9
9
  fileLogger = require('./logger').fileLogger,
10
10
  utils = require('./utils');
11
-
12
- const { AUTH_REGEX, REDACTED_AUTH } = require("./constants");
11
+
12
+ const { AUTH_REGEX, REDACTED_AUTH, REDACTED, CLI_ARGS_REGEX, RAW_ARGS_REGEX } = require("./constants");
13
13
 
14
14
  function get_version(package_name) {
15
15
  try {
@@ -172,6 +172,31 @@ function isUsageReportingEnabled() {
172
172
  return process.env.DISABLE_USAGE_REPORTING;
173
173
  }
174
174
 
175
+ function redactBsConfig(bsConfig) {
176
+ if(typeof bsConfig === 'object' && !utils.isUndefined(bsConfig.run_settings)) {
177
+ if(!utils.isUndefined(bsConfig.run_settings["projectId"])) { bsConfig.run_settings["projectId"] = REDACTED }
178
+ if(!utils.isUndefined(bsConfig.run_settings["record-key"])) { bsConfig.run_settings["record-key"] = REDACTED }
179
+ }
180
+ }
181
+
182
+ function redactArgs(args) {
183
+ if(typeof args === 'object' && !utils.isUndefined(args.cli_args)) {
184
+ if(!utils.isUndefined(args.cli_args["projectId"])) { args.cli_args["projectId"] = REDACTED }
185
+ if(!utils.isUndefined(args.cli_args["project-id"])) { args.cli_args["project-id"] = REDACTED }
186
+ if(!utils.isUndefined(args.cli_args["record-key"])) { args.cli_args["record-key"] = REDACTED }
187
+ if(!utils.isUndefined(args.cli_args["recordKey"])) { args.cli_args["recordKey"] = REDACTED }
188
+ }
189
+ }
190
+
191
+ function redactRecordCaps(bsConfig, args) {
192
+ redactBsConfig(bsConfig);
193
+ redactArgs(args);
194
+ }
195
+
196
+ function redactKeys(str, regex, redact) {
197
+ return str.replace(regex, redact);
198
+ }
199
+
175
200
  function send(args) {
176
201
  if (isUsageReportingEnabled() === "true") return;
177
202
 
@@ -179,16 +204,20 @@ function send(args) {
179
204
  let runSettings = "";
180
205
  let sanitizedbsConfig = "";
181
206
  let cli_details = cli_version_and_path(bsConfig);
182
- let data = utils.isUndefined(args.data) ? {} : args.data;
183
207
 
208
+ redactRecordCaps(bsConfig, args);
209
+
210
+ let data = utils.isUndefined(args.data) ? {} : args.data;
184
211
  if (bsConfig && bsConfig.run_settings) {
185
212
  runSettings = bsConfig.run_settings;
186
213
  data.cypress_version = bsConfig.run_settings.cypress_version;
187
214
  }
188
-
189
- sanitizedbsConfig = `${(typeof bsConfig === 'string') ? bsConfig :
190
- JSON.stringify(bsConfig)}`.replace(AUTH_REGEX, REDACTED_AUTH);
191
-
215
+
216
+ sanitizedbsConfig = redactKeys(`${(typeof bsConfig === 'string') ? bsConfig :
217
+ JSON.stringify(bsConfig)}`, AUTH_REGEX, REDACTED_AUTH);
218
+ args.cli_args = args.cli_args && redactKeys(JSON.stringify(args.cli_args), CLI_ARGS_REGEX, REDACTED);
219
+ args.raw_args = args.raw_args && redactKeys(JSON.stringify(args.raw_args), RAW_ARGS_REGEX, REDACTED);
220
+
192
221
  delete args.bstack_config;
193
222
 
194
223
  let zipUploadDetails = {