browserstack-cypress-cli 1.13.1 → 1.15.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.
@@ -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,10 @@ 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",
108
+ NODE_VERSION_PARSING_ERROR: "We weren't able to successfully parse the specified nodeVersion. We will be using the default nodeVersion to run your tests."
105
109
  };
106
110
 
107
111
  const cliMessages = {
@@ -145,7 +149,11 @@ const cliMessages = {
145
149
  REPORTER: "Specify the custom reporter to use",
146
150
  REPORTER_OPTIONS: "Specify reporter options for custom reporter",
147
151
  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."
152
+ 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.",
153
+ 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.",
154
+ 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",
155
+ 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.",
156
+ NODE_VERSION: "Pass the node version that you want BrowserStack to use to run your Cypress tests on."
149
157
  },
150
158
  COMMON: {
151
159
  DISABLE_USAGE_REPORTING: "Disable usage reporting",
@@ -155,6 +163,7 @@ const cliMessages = {
155
163
  NO_NPM_WARNING: "No NPM warning if npm_dependencies is empty",
156
164
  CONFIG_DEMAND: "config file is required",
157
165
  CONFIG_FILE_PATH: "Path to BrowserStack config",
166
+ DEBUG: "Use this option to get debug logs on the CLI console.",
158
167
  },
159
168
  GENERATE_REPORT: {
160
169
  INFO: "Generates the build report"
@@ -245,6 +254,8 @@ const REDACTED_AUTH =`auth: { "username": ${REDACTED}, "access_key": ${REDACTED}
245
254
 
246
255
  const SPEC_TIMEOUT_LIMIT = 120 // IN MINS
247
256
 
257
+ const CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY = "custom_errors_to_print";
258
+
248
259
  module.exports = Object.freeze({
249
260
  syncCLI,
250
261
  userMessages,
@@ -269,5 +280,6 @@ module.exports = Object.freeze({
269
280
  REDACTED_AUTH,
270
281
  REDACTED,
271
282
  BUILD_FAILED_EXIT_CODE,
272
- SPEC_TIMEOUT_LIMIT
283
+ SPEC_TIMEOUT_LIMIT,
284
+ CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY
273
285
  });
@@ -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;
@@ -15,11 +15,13 @@ let nodeProcess;
15
15
  const setupPackageFolder = (runSettings, directoryPath) => {
16
16
  return new Promise(function (resolve, reject) {
17
17
  fileHelpers.deletePackageArchieve(false);
18
+ logger.debug(`Started creating ${directoryPath} folder`);
18
19
  fs.mkdir(directoryPath, function (err) {
19
20
  try {
20
21
  if (err) {
21
22
  return reject(err);
22
23
  }
24
+ logger.debug(`Completed creating ${directoryPath}`);
23
25
  let packageJSON = {};
24
26
  if (typeof runSettings.package_config_options === 'object') {
25
27
  Object.assign(packageJSON, runSettings.package_config_options);
@@ -39,12 +41,16 @@ const setupPackageFolder = (runSettings, directoryPath) => {
39
41
  let sourceNpmrc = path.join(cypressFolderPath, ".npmrc");
40
42
  let destNpmrc = path.join(directoryPath, ".npmrc");
41
43
  if (fs.existsSync(sourceNpmrc)) {
44
+ logger.debug(`Copying .npmrc file from ${sourceNpmrc} to ${destNpmrc}`);
42
45
  fs.copyFileSync(sourceNpmrc, destNpmrc);
43
46
  }
47
+ logger.debug(`${packagePath} file created with ${packageJSONString}`);
44
48
  return resolve("Package file created");
45
49
  }
50
+ logger.debug("Nothing in package file");
46
51
  return reject("Nothing in package file");
47
52
  } catch(error) {
53
+ logger.debug(`Creating ${directoryPath} failed with error ${error}`);
48
54
  return reject(error);
49
55
  }
50
56
  })
@@ -59,12 +65,12 @@ const packageInstall = (packageDir) => {
59
65
  resolve('Packages were installed successfully.');
60
66
  } else {
61
67
  logger.error(`Some error occurred while installing packages. Error code ${code}`);
62
- reject('Packages were not installed successfully. Error code ${code}');
68
+ reject(`Packages were not installed successfully. Error code ${code}`);
63
69
  }
64
70
  };
65
71
  const nodeProcessErrorCallback = (error) => {
66
- logger.error(`Some error occurred while installing packages: ${util.inspect(error)}`);
67
- reject(`Packages were not installed successfully. Error Description ${util.inspect(error)}`);
72
+ logger.error(`Some error occurred while installing packages: %j`, error);
73
+ reject(`Packages were not installed successfully. Error Description ${util.format('%j', error)}`);
68
74
  };
69
75
  nodeProcess = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install', '--loglevel', 'verbose', '>', '../npm_install_debug.log', '2>&1'], {cwd: packageDir, shell: true});
70
76
  nodeProcess.on('close', nodeProcessCloseCallback);
@@ -82,6 +88,7 @@ const packageArchiver = (packageDir, packageFile) => {
82
88
  if (err.code === 'ENOENT') {
83
89
  logger.info(err);
84
90
  } else {
91
+ logger.debug(`Archiving of node_modules failed with error ${err}`);
85
92
  reject(err);
86
93
  }
87
94
  });
@@ -95,6 +102,7 @@ const packageArchiver = (packageDir, packageFile) => {
95
102
  });
96
103
 
97
104
  archive.on('error', function (err) {
105
+ logger.debug(`Archiving of node_modules failed with error ${err}`);
98
106
  reject(err);
99
107
  });
100
108
 
@@ -110,24 +118,32 @@ const packageWrapper = (bsConfig, packageDir, packageFile, md5data, instrumentBl
110
118
  packageArchieveCreated: false
111
119
  };
112
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.")
113
122
  return resolve(obj);
114
123
  }
115
124
  logger.info(Constants.userMessages.NPM_INSTALL_AND_UPLOAD);
116
125
  instrumentBlocks.markBlockStart("packageInstaller.folderSetup");
126
+ logger.debug("Started setting up package folder");
117
127
  return setupPackageFolder(bsConfig.run_settings, packageDir).then((_result) => {
128
+ logger.debug("Completed setting up package folder");
118
129
  process.env.CYPRESS_INSTALL_BINARY = 0
119
130
  instrumentBlocks.markBlockEnd("packageInstaller.folderSetup");
120
131
  instrumentBlocks.markBlockStart("packageInstaller.packageInstall");
132
+ logger.debug("Started installing dependencies specified in browserstack.json");
121
133
  return packageInstall(packageDir);
122
134
  }).then((_result) => {
135
+ logger.debug("Completed installing dependencies");
123
136
  instrumentBlocks.markBlockEnd("packageInstaller.packageInstall");
124
137
  instrumentBlocks.markBlockStart("packageInstaller.packageArchive");
138
+ logger.debug("Started archiving node_modules")
125
139
  return packageArchiver(packageDir, packageFile);
126
140
  }).then((_result) => {
141
+ logger.debug("Archiving of node_modules completed");
127
142
  instrumentBlocks.markBlockEnd("packageInstaller.packageArchive");
128
143
  Object.assign(obj, { packageArchieveCreated: true });
129
144
  return resolve(obj);
130
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.`);
131
147
  obj.error = err.stack ? err.stack.toString().substring(0,100) : err.toString().substring(0,100);
132
148
  return resolve(obj);
133
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,7 +8,7 @@ const cp = require("child_process"),
8
8
  const config = require('./config'),
9
9
  fileLogger = require('./logger').fileLogger,
10
10
  utils = require('./utils');
11
-
11
+
12
12
  const { AUTH_REGEX, REDACTED_AUTH, REDACTED, CLI_ARGS_REGEX, RAW_ARGS_REGEX } = require("./constants");
13
13
 
14
14
  function get_version(package_name) {
@@ -172,6 +172,27 @@ 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
+
175
196
  function redactKeys(str, regex, redact) {
176
197
  return str.replace(regex, redact);
177
198
  }
@@ -183,8 +204,10 @@ function send(args) {
183
204
  let runSettings = "";
184
205
  let sanitizedbsConfig = "";
185
206
  let cli_details = cli_version_and_path(bsConfig);
186
- let data = utils.isUndefined(args.data) ? {} : args.data;
187
207
 
208
+ redactRecordCaps(bsConfig, args);
209
+
210
+ let data = utils.isUndefined(args.data) ? {} : args.data;
188
211
  if (bsConfig && bsConfig.run_settings) {
189
212
  runSettings = bsConfig.run_settings;
190
213
  data.cypress_version = bsConfig.run_settings.cypress_version;
@@ -268,4 +291,5 @@ function send(args) {
268
291
  module.exports = {
269
292
  send,
270
293
  cli_version_and_path,
294
+ get_version
271
295
  };