browserstack-cypress-cli 1.12.1 → 1.14.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.
@@ -1,4 +1,5 @@
1
1
  const logger = require("../logger").syncCliLogger;
2
+ const winstonlogger = require("../logger").winstonLogger;
2
3
 
3
4
  /**
4
5
  *
@@ -16,7 +17,7 @@ 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,
@@ -32,6 +33,21 @@ let printSpecsRunSummary = (data, machines) => {
32
33
  logger.info(`Total tests: ${summary.total}, passed: ${summary.passed}, failed: ${summary.failed}, skipped: ${summary.skipped}`);
33
34
  logger.info(`Done in ${data.duration/1000} seconds using ${machines} machines\n`);
34
35
 
36
+ if (customErrorsToPrint && customErrorsToPrint.length > 0) {
37
+ for (const error of customErrorsToPrint) {
38
+ switch(error.level) {
39
+ case 'info':
40
+ winstonlogger.info(error.message);
41
+ break;
42
+ case 'error':
43
+ winstonlogger.error(error.message);
44
+ break;
45
+ default:
46
+ winstonlogger.warn(error.message);
47
+ }
48
+ }
49
+ }
50
+
35
51
  resolve(data.exitCode);
36
52
  })
37
53
  };
@@ -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,7 +89,10 @@ 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
 
@@ -107,6 +112,7 @@ 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 {
@@ -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
  }
@@ -200,6 +210,17 @@ let writeToTable = (combination, specName, status) => {
200
210
  stream.write([combination , ":", `${specName} ${status}`]);
201
211
  }
202
212
 
213
+ let addCustomErrorToPrint = (error_object) => {
214
+ if (error_object["should_be_unique"]) {
215
+ for (const error of specSummary.customErrorsToPrint) {
216
+ if (error.id === error_object.id) {
217
+ return;
218
+ }
219
+ }
220
+ }
221
+ specSummary.customErrorsToPrint.push(error_object);
222
+ }
223
+
203
224
  let addSpecToSummary = (specName, status, combination, session_id) => {
204
225
  // Format for part 3: {specName: 'spec1.failed.js', status: 'Failed', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'},
205
226
  specSummary["specs"].push({
@@ -4,11 +4,15 @@ const syncSpecsLogs = require('./sync/syncSpecsLogs'),
4
4
  specsSummary = require('./sync/specsSummary');
5
5
 
6
6
  exports.pollBuildStatus = (bsConfig, buildDetails) => {
7
+ let customErrorsToPrint;
7
8
  return new Promise((resolve, reject) => {
8
9
  syncSpecsLogs.printSpecsStatus(bsConfig, buildDetails).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 = {
@@ -7,6 +7,7 @@ const getmac = require('getmac').default;
7
7
  const { v4: uuidv4 } = require('uuid');
8
8
  const browserstack = require('browserstack-local');
9
9
  const crypto = require('crypto');
10
+ const util = require('util');
10
11
 
11
12
  const usageReporting = require("./usageReporting"),
12
13
  logger = require("./logger").winstonLogger,
@@ -15,7 +16,8 @@ const usageReporting = require("./usageReporting"),
15
16
  syncCliLogger = require("../helpers/logger").syncCliLogger,
16
17
  fileHelpers = require("./fileHelpers"),
17
18
  config = require("../helpers/config"),
18
- pkg = require('../../package.json');
19
+ pkg = require('../../package.json'),
20
+ transports = require('./logger').transports;
19
21
 
20
22
  const request = require('request');
21
23
 
@@ -153,6 +155,7 @@ exports.setUsageReportingFlag = (bsConfig, disableUsageReporting) => {
153
155
  } else {
154
156
  process.env.DISABLE_USAGE_REPORTING = disableUsageReporting;
155
157
  }
158
+ logger.debug(`Setting disable_usage_reporting flag as ${process.env.DISABLE_USAGE_REPORTING}`);
156
159
  };
157
160
 
158
161
  exports.getParallels = (bsConfig, args) => {
@@ -225,6 +228,7 @@ exports.setDefaults = (bsConfig, args) => {
225
228
  exports.setUsername = (bsConfig, args) => {
226
229
  if (!this.isUndefined(args.username)) {
227
230
  bsConfig["auth"]["username"] = args.username;
231
+ logger.debug(`Reading username from command line = ${args.username}`);
228
232
  } else if (!this.isUndefined(process.env.BROWSERSTACK_USERNAME)) {
229
233
  bsConfig["auth"]["username"] = process.env.BROWSERSTACK_USERNAME;
230
234
  logger.info(
@@ -236,6 +240,7 @@ exports.setUsername = (bsConfig, args) => {
236
240
  exports.setAccessKey = (bsConfig, args) => {
237
241
  if (!this.isUndefined(args.key)) {
238
242
  bsConfig["auth"]["access_key"] = args.key;
243
+ logger.debug("Reading access_key from command line");
239
244
  } else if (!this.isUndefined(process.env.BROWSERSTACK_ACCESS_KEY)) {
240
245
  bsConfig["auth"]["access_key"] = process.env.BROWSERSTACK_ACCESS_KEY;
241
246
  logger.info(
@@ -246,6 +251,7 @@ exports.setAccessKey = (bsConfig, args) => {
246
251
 
247
252
  exports.setBuildName = (bsConfig, args) => {
248
253
  if (!this.isUndefined(args["build-name"])) {
254
+ logger.debug(`Reading build name from command line = ${args["build-name"]}`);
249
255
  bsConfig["run_settings"]["build_name"] = args["build-name"];
250
256
  }
251
257
  };
@@ -285,6 +291,8 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
285
291
  bsConfig.run_settings.cypressConfigFilePath = path.join(bsConfig.run_settings.cypress_proj_dir, 'cypress.json');
286
292
  bsConfig.run_settings.cypressProjectDir = bsConfig.run_settings.cypress_proj_dir;
287
293
  }
294
+ logger.debug(`Setting cypress config file path = ${bsConfig.run_settings.cypressConfigFilePath}`);
295
+ logger.debug(`Setting cypress project dir = ${bsConfig.run_settings.cypressProjDir}`);
288
296
  }
289
297
 
290
298
  exports.verifyGeolocationOption = () => {
@@ -307,6 +315,60 @@ exports.setGeolocation = (bsConfig, args) => {
307
315
  } else {
308
316
  bsConfig.run_settings.geolocation = bsConfig.run_settings.geolocation.toUpperCase();
309
317
  }
318
+ logger.debug(`Setting geolocation = ${bsConfig.run_settings.geolocation}`);
319
+ }
320
+
321
+ exports.isSpecTimeoutArgPassed = () => {
322
+ return this.searchForOption('--spec-timeout') || this.searchForOption('-t');
323
+ }
324
+ exports.setSpecTimeout = (bsConfig, args) => {
325
+ let specTimeout = null;
326
+ if(this.isSpecTimeoutArgPassed()) {
327
+ if(!this.isUndefined(args.specTimeout)) {
328
+ specTimeout = args.specTimeout;
329
+ } else {
330
+ specTimeout = 'undefined'
331
+ }
332
+ } else if (!this.isUndefined(bsConfig.run_settings.spec_timeout)) {
333
+ specTimeout = bsConfig.run_settings.spec_timeout;
334
+ }
335
+ bsConfig.run_settings.spec_timeout = specTimeout;
336
+ logger.debug(`Setting spec timeout = ${specTimeout}`);
337
+ }
338
+
339
+ exports.setRecordFlag = (bsConfig, args) => {
340
+ if(!this.isUndefined(args["record"])) {
341
+ return true;
342
+ }
343
+ return bsConfig.run_settings["record"];
344
+ }
345
+
346
+ exports.setRecordKeyFlag = (bsConfig, args) => {
347
+ if(!this.isUndefined(args["record-key"])) {
348
+ return args["record-key"];
349
+ } else if (!this.isUndefined(process.env.CYPRESS_RECORD_KEY)) {
350
+ return process.env.CYPRESS_RECORD_KEY;
351
+ }
352
+ return bsConfig.run_settings["record-key"];
353
+ }
354
+
355
+ exports.setProjectId = (bsConfig, args) => {
356
+ if(!this.isUndefined(args["projectId"])) {
357
+ return args["projectId"];
358
+ } else if(!this.isUndefined(process.env.CYPRESS_PROJECT_ID)) {
359
+ return process.env.CYPRESS_PROJECT_ID;
360
+ } else if(!this.isUndefined(bsConfig.run_settings["projectId"])) {
361
+ return bsConfig.run_settings["projectId"];
362
+ } else {
363
+ let cypressJson = this.getCypressJSON(bsConfig);
364
+ if (!this.isUndefined(cypressJson) && !this.isUndefined(cypressJson["projectId"])) { return cypressJson["projectId"]; }
365
+ }
366
+ }
367
+
368
+ exports.setRecordCaps = (bsConfig, args) => {
369
+ bsConfig.run_settings["record"] = this.setRecordFlag(bsConfig, args);
370
+ bsConfig.run_settings["record-key"] = this.setRecordKeyFlag(bsConfig, args);
371
+ bsConfig.run_settings["projectId"] = this.setProjectId(bsConfig, args);
310
372
  }
311
373
 
312
374
  // specs can be passed from bstack configuration file
@@ -317,6 +379,7 @@ exports.setUserSpecs = (bsConfig, args) => {
317
379
 
318
380
  if (!this.isUndefined(args.specs)) {
319
381
  bsConfig.run_settings.specs = this.fixCommaSeparatedString(args.specs);
382
+ logger.debug(`Specs provided to run using CLI argument = ${bsConfig.run_settings.specs}`);
320
383
  } else if (!this.isUndefined(bsConfigSpecs) && Array.isArray(bsConfigSpecs)) {
321
384
  bsConfig.run_settings.specs = bsConfigSpecs.join(',');
322
385
  } else if (!this.isUndefined(bsConfigSpecs) && typeof(bsConfigSpecs) == "string") {
@@ -347,6 +410,8 @@ exports.setTestEnvs = (bsConfig, args) => {
347
410
  } else {
348
411
  bsConfig.run_settings.env = Object.keys(envKeys).map(key => (`${key}=${envKeys[key]}`)).join(',');
349
412
  }
413
+
414
+ logger.debug(`Setting env vars = ${bsConfig.run_settings.env}`);
350
415
  }
351
416
 
352
417
  exports.setSystemEnvs = (bsConfig) => {
@@ -374,6 +439,8 @@ exports.setSystemEnvs = (bsConfig) => {
374
439
  } else {
375
440
  bsConfig.run_settings.system_env_vars = Object.keys(envKeys).map(key => (`${key}=${envKeys[key]}`));
376
441
  }
442
+
443
+ logger.debug(`Setting system env vars = ${bsConfig.run_settings.system_env_vars}`);
377
444
  }
378
445
 
379
446
  exports.getKeysMatchingPattern = (obj, pattern) => {
@@ -389,10 +456,26 @@ exports.fixCommaSeparatedString = (string) => {
389
456
 
390
457
  exports.isUndefined = value => (value === undefined || value === null);
391
458
 
459
+ exports.isPositiveInteger = (str) => {
460
+ if (typeof str !== 'string') {
461
+ return false;
462
+ }
463
+
464
+ const num = Number(str);
465
+
466
+ if (this.isInteger(num) && num > 0) {
467
+ return true;
468
+ }
469
+
470
+ return false;
471
+ }
472
+
392
473
  exports.isTrueString = value => (!this.isUndefined(value) && value.toString().toLowerCase() === 'true');
393
474
 
394
475
  exports.isFloat = (value) => Number(value) && Number(value) % 1 !== 0;
395
476
 
477
+ exports.isInteger = (value) => Number.isInteger(value);
478
+
396
479
  exports.nonEmptyArray = (value) => {
397
480
  if(!this.isUndefined(value) && value && value.length) {
398
481
  return true;
@@ -432,6 +515,7 @@ exports.configCreated = (args) => {
432
515
 
433
516
  exports.exportResults = (buildId, buildUrl) => {
434
517
  let data = "BUILD_ID=" + buildId + "\nBUILD_URL=" + buildUrl;
518
+ logger.debug("Writing build results to log/build_results.txt");
435
519
  fs.writeFileSync("log/build_results.txt", data, function (err) {
436
520
  if (err) {
437
521
  logger.warn(
@@ -552,6 +636,7 @@ exports.setLocal = (bsConfig, args) => {
552
636
  local = true;
553
637
  }
554
638
  bsConfig['connection_settings']['local'] = local;
639
+ logger.debug(`Reading local setting from command line as ${local}`);
555
640
  } else if (!this.isUndefined(process.env.BROWSERSTACK_LOCAL)) {
556
641
  let local = false;
557
642
  if (String(process.env.BROWSERSTACK_LOCAL).toLowerCase() === 'true') {
@@ -626,6 +711,7 @@ exports.setLocalMode = (bsConfig, args) => {
626
711
  if (localModeInferred && localModeUndefined) {
627
712
  bsConfig.connection_settings.local_mode_inferred = local_mode;
628
713
  }
714
+ logger.debug(`local_mode set to ${bsConfig.connection_settings.local_mode_inferred}`);
629
715
  }
630
716
  };
631
717
 
@@ -645,6 +731,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
645
731
  process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING = "true";
646
732
  }
647
733
  if (!localIdentifierRunning){
734
+ logger.debug(`Local binary with identifier ${bsConfig["connection_settings"]["local_identifier"]} not running. Starting a new connection.`);
648
735
  bsConfig.connection_settings.usedAutoLocal = true;
649
736
  var bs_local = this.getLocalBinary();
650
737
  var bs_local_args = this.setLocalArgs(bsConfig, args);
@@ -655,6 +742,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
655
742
  process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING = "true";
656
743
  resolve(bs_local);
657
744
  } else {
745
+ logger.debug(`Error occured while starting a new Local connection with error :`,localStartError);
658
746
  let message = `name: ${localStartError.name}, message: ${localStartError.message}, extra: ${localStartError.extra}`,
659
747
  errorCode = "local_start_error";
660
748
  that.sendUsageReport(
@@ -686,6 +774,7 @@ exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
686
774
  if (that.isUndefined(localStopError)) {
687
775
  resolve();
688
776
  } else {
777
+ logger.debug(`Stopping local binary failed with error`, localStopError);
689
778
  let message = `name: ${localStopError.name}, message: ${localStopError.message}, extra: ${localStopError.extra}`,
690
779
  errorCode = 'local_stop_error';
691
780
  that.sendUsageReport(
@@ -734,6 +823,7 @@ exports.generateLocalIdentifier = (mode) => {
734
823
  };
735
824
 
736
825
  exports.checkLocalBinaryRunning = (bsConfig, localIdentifier) => {
826
+ logger.debug("Checking if local binary running");
737
827
  let options = {
738
828
  url: `${config.cypress_v1}/local_binary_running_check`,
739
829
  auth: {
@@ -760,6 +850,7 @@ exports.checkLocalBinaryRunning = (bsConfig, localIdentifier) => {
760
850
  exports.setLocalConfigFile = (bsConfig, args) => {
761
851
  if(!this.isUndefined(args.localConfigFile)){
762
852
  bsConfig['connection_settings']['local_config_file'] = args.localConfigFile;
853
+ logger.debug(`local_config_file set to ${bsConfig['connection_settings']['local_config_file']}`);
763
854
  }
764
855
  };
765
856
 
@@ -767,6 +858,7 @@ exports.setHeaded = (bsConfig, args) => {
767
858
  if (!this.isUndefined(args.headed) && args.headed === true) {
768
859
  bsConfig.run_settings.headless = false;
769
860
  }
861
+ logger.debug(`headless mode set to ${bsConfig.run_settings.headless}`);
770
862
  };
771
863
 
772
864
  exports.setNoWrap = (_bsConfig, args) => {
@@ -775,6 +867,7 @@ exports.setNoWrap = (_bsConfig, args) => {
775
867
  } else {
776
868
  process.env.SYNC_NO_WRAP = false;
777
869
  }
870
+ logger.debug(`no-wrap set to ${process.env.SYNC_NO_WRAP}`);
778
871
  }
779
872
 
780
873
  exports.getFilesToIgnore = (runSettings, excludeFiles, logging = true) => {
@@ -799,6 +892,7 @@ exports.getNumberOfSpecFiles = (bsConfig, args, cypressJson) => {
799
892
  let globSearchPattern = this.sanitizeSpecsPattern(bsConfig.run_settings.specs) || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`;
800
893
  let ignoreFiles = args.exclude || bsConfig.run_settings.exclude;
801
894
  let files = glob.sync(globSearchPattern, {cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles});
895
+ logger.debug(`${files ? files.length : 0} spec files found at ${testFolderPath}`);
802
896
  return files;
803
897
  };
804
898
 
@@ -915,6 +1009,7 @@ exports.setBrowsers = async (bsConfig, args) => {
915
1009
  browserHash['versions'].push(this.isUndefined(browserDetails[1]) ? "latest" : browserDetails[1].trim())
916
1010
  bsConfig["browsers"].push(browserHash)
917
1011
  });
1012
+ logger.debug(`Browsers provided ${bsConfig["browsers"]}`);
918
1013
  } catch(err){
919
1014
  reject(Constants.validationMessages.INVALID_BROWSER_ARGS)
920
1015
  }
@@ -926,6 +1021,7 @@ exports.setBrowsers = async (bsConfig, args) => {
926
1021
  exports.setConfig = (bsConfig, args) => {
927
1022
  if (!this.isUndefined(args.config)) {
928
1023
  bsConfig["run_settings"]["config"] = args.config
1024
+ logger.debug(`Config set to ${bsConfig["run_settings"]["config"]}`);
929
1025
  }
930
1026
  }
931
1027
 
@@ -933,9 +1029,11 @@ exports.setConfig = (bsConfig, args) => {
933
1029
  exports.setOtherConfigs = (bsConfig, args) => {
934
1030
  if (!this.isUndefined(args.reporter)) {
935
1031
  bsConfig["run_settings"]["reporter"] = args.reporter;
1032
+ logger.debug(`reporter set to ${args.reporter}`);
936
1033
  }
937
1034
  if (!this.isUndefined(args.reporterOptions)) {
938
1035
  bsConfig["run_settings"]["reporter_options"] = args.reporterOptions;
1036
+ logger.debug(`reporter-options set to ${args.reporterOptions}`);
939
1037
  }
940
1038
  }
941
1039
 
@@ -967,8 +1065,30 @@ exports.setCLIMode = (bsConfig, args) => {
967
1065
  if(!this.isUndefined(args.async) && args.async){
968
1066
  args.sync = false;
969
1067
  }
1068
+ logger.debug(`sync mode set to ${args.sync}`);
1069
+ }
1070
+
1071
+ exports.formatRequest = (err, resp, body) => {
1072
+ return {
1073
+ err,
1074
+ status: resp ? resp.statusCode : null,
1075
+ body: body ? util.format('%j', body) : null
1076
+ }
1077
+ }
1078
+
1079
+ exports.setDebugMode = (args) => {
1080
+ if(args.cliDebug || String(process.env.DEBUG).toLowerCase() === 'true'){
1081
+ args.cliDebug ?
1082
+ logger.info("CLI is running with the --cli-debug argument. Running CLI in the debug mode...") :
1083
+ logger.info("DEBUG environment variable set to 'true'. Running CLI in the debug mode...") ;
1084
+ transports.loggerConsole.level = 'debug';
1085
+ return;
1086
+ }
1087
+
1088
+ transports.loggerConsole.level = 'info';
970
1089
  }
971
1090
 
1091
+
972
1092
  exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
973
1093
  let that = this;
974
1094
  return new Promise(function (resolve, reject) {
@@ -1078,5 +1198,7 @@ exports.getVideoConfig = (cypressJson) => {
1078
1198
  if (!this.isUndefined(cypressJson.video)) conf.video = cypressJson.video;
1079
1199
  if (!this.isUndefined(cypressJson.videoUploadOnPasses)) conf.videoUploadOnPasses = cypressJson.videoUploadOnPasses;
1080
1200
 
1201
+ logger.debug(`Setting video = ${conf.video}`);
1202
+ logger.debug(`Setting videoUploadOnPasses = ${conf.videoUploadOnPasses}`);
1081
1203
  return conf;
1082
1204
  }
@@ -52,7 +52,7 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
52
52
  var r = request.post(options, function (err, resp, body) {
53
53
 
54
54
  if (err) {
55
- reject(err);
55
+ reject({message: err, stacktrace: utils.formatRequest(err, resp, body)});
56
56
  } else {
57
57
  try {
58
58
  responseData = JSON.parse(body);
@@ -63,22 +63,26 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
63
63
  if (resp.statusCode == 401) {
64
64
  if (responseData && responseData["error"]) {
65
65
  responseData["time"] = Date.now() - obj.startTime;
66
- return reject(responseData["error"]);
66
+ return reject({message: responseData["error"], stacktrace: utils.formatRequest(err, resp, body)});
67
67
  } else {
68
- return reject(Constants.validationMessages.INVALID_DEFAULT_AUTH_PARAMS);
68
+ return reject({message: Constants.validationMessages.INVALID_DEFAULT_AUTH_PARAMS, stacktrace: utils.formatRequest(err, resp, body)});
69
69
  }
70
70
  }
71
71
  if (!opts.propogateError){
72
- return resolve({});
72
+ purgeUploadBar(obj);
73
+ if (resp.statusCode == 413) {
74
+ return resolve({warn: Constants.userMessages.NODE_MODULES_LIMIT_EXCEEDED.replace("%SIZE%", (size / 1000000).toFixed(2))});
75
+ }
76
+ return resolve({})
73
77
  }
74
78
  if(responseData && responseData["error"]){
75
79
  responseData["time"] = Date.now() - obj.startTime;
76
- reject(responseData["error"]);
80
+ reject({message: responseData["error"], stacktrace: utils.formatRequest(err, resp, body)});
77
81
  } else {
78
82
  if (resp.statusCode == 413) {
79
- reject(Constants.userMessages.ZIP_UPLOAD_LIMIT_EXCEEDED);
83
+ reject({message: Constants.userMessages.ZIP_UPLOAD_LIMIT_EXCEEDED, stacktrace: utils.formatRequest(err, resp, body)});
80
84
  } else {
81
- reject(Constants.userMessages.ZIP_UPLOADER_NOT_REACHABLE);
85
+ reject({message: Constants.userMessages.ZIP_UPLOADER_NOT_REACHABLE, stacktrace: utils.formatRequest(err, resp, body)});
82
86
  }
83
87
  }
84
88
  } else {
@@ -137,6 +141,9 @@ const uploadCypressZip = (bsConfig, md5data, packageData) => {
137
141
  let npmPackageUpload = uploadSuits(bsConfig, config.packageFileName, npmOptions, npmPackageZipUploadObj);
138
142
  Promise.all([zipUpload, npmPackageUpload]).then(function (uploads) {
139
143
  uploads.forEach(upload => {
144
+ if(upload.warn) {
145
+ logger.warn(upload.warn);
146
+ }
140
147
  if(upload.zip_url && upload.time) {
141
148
  upload.tests_upload_time = upload.time;
142
149
  } else if (upload.npm_package_url && upload.time) {
@@ -147,9 +154,10 @@ const uploadCypressZip = (bsConfig, md5data, packageData) => {
147
154
  });
148
155
  return resolve(obj);
149
156
  }).catch((error) => {
150
- purgeUploadBar(testZipUploadObj);
151
- purgeUploadBar(npmPackageZipUploadObj);
152
- return reject(error);
157
+ testZipUploadObj.bar1 && purgeUploadBar(testZipUploadObj);
158
+ npmPackageZipUploadObj.bar1 && purgeUploadBar(npmPackageZipUploadObj);
159
+ logger.error(error.stacktrace)
160
+ return reject(error.message);
153
161
  })
154
162
  })
155
163
  }
package/bin/runner.js CHANGED
@@ -43,11 +43,20 @@ const configFileOptions = {
43
43
  },
44
44
  }
45
45
 
46
+ const debugModeOptions = {
47
+ 'cli-debug': {
48
+ default: false,
49
+ describe: Constants.cliMessages.COMMON.DEBUG,
50
+ type: "boolean"
51
+ },
52
+ }
53
+
46
54
  const commonBuildOptions = {
47
55
  ...configFileOptions,
48
56
  ...disableUsageReportingOptions,
49
57
  ...usernameOptions,
50
58
  ...accessKeyOptions,
59
+ ...debugModeOptions,
51
60
  }
52
61
 
53
62
  function checkCommands(yargs, argv, numRequired) {
@@ -168,6 +177,12 @@ var argv = yargs
168
177
  type: "string",
169
178
  default: undefined
170
179
  },
180
+ 't': {
181
+ alias: ['specTimeout'],
182
+ default: undefined,
183
+ describe: Constants.cliMessages.RUN.SPEC_TIMEOUT,
184
+ type: "string"
185
+ },
171
186
  'disable-npm-warning': {
172
187
  default: false,
173
188
  description: Constants.cliMessages.COMMON.NO_NPM_WARNING,
@@ -237,6 +252,20 @@ var argv = yargs
237
252
  describe: Constants.cliMessages.RUN.REPORTER_OPTIONS,
238
253
  type: "string"
239
254
  },
255
+ 'record': {
256
+ describe: Constants.cliMessages.RUN.RECORD,
257
+ type: "boolean"
258
+ },
259
+ 'record-key': {
260
+ default: undefined,
261
+ describe: Constants.cliMessages.RUN.RECORD_KEY,
262
+ type: "string"
263
+ },
264
+ 'projectId': {
265
+ default: undefined,
266
+ describe: Constants.cliMessages.RUN.PROJECT_ID,
267
+ type: "string"
268
+ }
240
269
  })
241
270
  .help('help')
242
271
  .wrap(null)
@@ -56,7 +56,7 @@ module.exports = function () {
56
56
  "project_name": "project-name",
57
57
  "build_name": "build-name",
58
58
  "exclude": [],
59
- "parallels": "Here goes the number of parallels you want to run",
59
+ "parallels": "Number of parallels you want to run",
60
60
  "npm_dependencies": {
61
61
  },
62
62
  "package_config_options": {