browserstack-cypress-cli 1.14.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.
@@ -3,7 +3,8 @@
3
3
  const logger = require("../helpers/logger").winstonLogger,
4
4
  Constants = require("../helpers/constants"),
5
5
  utils = require("../helpers/utils"),
6
- downloadBuildArtifacts = require('../helpers/buildArtifacts').downloadBuildArtifacts;
6
+ downloadBuildArtifacts = require('../helpers/buildArtifacts').downloadBuildArtifacts,
7
+ getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails;
7
8
 
8
9
 
9
10
  module.exports = async function generateDownloads(args, rawArgs) {
@@ -19,6 +20,8 @@ module.exports = async function generateDownloads(args, rawArgs) {
19
20
  // accept the access key from command line if provided
20
21
  utils.setAccessKey(bsConfig, args);
21
22
 
23
+ let buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
24
+
22
25
  utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
23
26
 
24
27
  // set cypress config filename
@@ -28,8 +31,8 @@ module.exports = async function generateDownloads(args, rawArgs) {
28
31
  let errorCode = null;
29
32
  let buildId = args._[1];
30
33
 
31
- await downloadBuildArtifacts(bsConfig, buildId, args, rawArgs);
32
- utils.sendUsageReport(bsConfig, args, Constants.usageReportingConstants.GENERATE_DOWNLOADS, messageType, errorCode, null, rawArgs);
34
+ await downloadBuildArtifacts(bsConfig, buildId, args, rawArgs, buildReportData);
35
+ utils.sendUsageReport(bsConfig, args, Constants.usageReportingConstants.GENERATE_DOWNLOADS, messageType, errorCode, buildReportData, rawArgs);
33
36
  }).catch(function (err) {
34
37
  logger.error(err);
35
38
  utils.setUsageReportingFlag(null, args.disableUsageReporting);
@@ -3,7 +3,8 @@
3
3
  const logger = require("../helpers/logger").winstonLogger,
4
4
  Constants = require("../helpers/constants"),
5
5
  utils = require("../helpers/utils"),
6
- reporterHTML = require('../helpers/reporterHTML');
6
+ reporterHTML = require('../helpers/reporterHTML'),
7
+ getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails;
7
8
 
8
9
 
9
10
  module.exports = function generateReport(args, rawArgs) {
@@ -20,17 +21,22 @@ module.exports = function generateReport(args, rawArgs) {
20
21
  // accept the access key from command line if provided
21
22
  utils.setAccessKey(bsConfig, args);
22
23
 
23
- utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
24
-
25
- // set cypress config filename
26
- utils.setCypressConfigFilename(bsConfig, args);
27
-
28
- let messageType = Constants.messageTypes.INFO;
29
- let errorCode = null;
30
- let buildId = args._[1];
31
-
32
- reportGenerator(bsConfig, buildId, args, rawArgs);
33
- utils.sendUsageReport(bsConfig, args, 'generate-report called', messageType, errorCode, null, rawArgs);
24
+ getInitialDetails(bsConfig, args, rawArgs).then((buildReportData) => {
25
+
26
+ utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
27
+
28
+ // set cypress config filename
29
+ utils.setCypressConfigFilename(bsConfig, args);
30
+
31
+ let messageType = Constants.messageTypes.INFO;
32
+ let errorCode = null;
33
+ let buildId = args._[1];
34
+
35
+ reportGenerator(bsConfig, buildId, args, rawArgs, buildReportData);
36
+ utils.sendUsageReport(bsConfig, args, 'generate-report called', messageType, errorCode, buildReportData, rawArgs);
37
+ }).catch((err) => {
38
+ logger.warn(err);
39
+ });
34
40
  }).catch(function (err) {
35
41
  logger.error(err);
36
42
  utils.setUsageReportingFlag(null, args.disableUsageReporting);
@@ -4,7 +4,8 @@ const request = require('request');
4
4
  const config = require("../helpers/config"),
5
5
  logger = require("../helpers/logger").winstonLogger,
6
6
  Constants = require("../helpers/constants"),
7
- utils = require("../helpers/utils");
7
+ utils = require("../helpers/utils"),
8
+ getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails;
8
9
 
9
10
  module.exports = function info(args, rawArgs) {
10
11
  let bsConfigPath = utils.getConfigPath(args.cf);
@@ -18,82 +19,86 @@ module.exports = function info(args, rawArgs) {
18
19
  // accept the access key from command line if provided
19
20
  utils.setAccessKey(bsConfig, args);
20
21
 
21
- utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
22
+ getInitialDetails(bsConfig, args, rawArgs).then((buildReportData) => {
22
23
 
23
- // set cypress config filename
24
- utils.setCypressConfigFilename(bsConfig, args);
24
+ utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
25
25
 
26
- let buildId = args._[1];
26
+ // set cypress config filename
27
+ utils.setCypressConfigFilename(bsConfig, args);
27
28
 
28
- let options = {
29
- url: config.buildUrl + buildId,
30
- auth: {
31
- user: bsConfig.auth.username,
32
- password: bsConfig.auth.access_key,
33
- },
34
- headers: {
35
- 'User-Agent': utils.getUserAgent(),
36
- },
37
- };
29
+ let buildId = args._[1];
38
30
 
39
- request.get(options, function (err, resp, body) {
40
- let message = null;
41
- let messageType = null;
42
- let errorCode = null;
43
-
44
- if (err) {
45
- message = Constants.userMessages.BUILD_INFO_FAILED;
46
- messageType = Constants.messageTypes.ERROR;
47
- errorCode = 'api_failed_build_info';
48
-
49
- logger.info(message);
50
- logger.error(utils.formatRequest(err, resp, body));
51
- } else {
52
- let build = null;
53
- try {
54
- build = JSON.parse(body);
55
- } catch (error) {
56
- build = null;
57
- }
58
-
59
- if (resp.statusCode == 299) {
60
- messageType = Constants.messageTypes.INFO;
61
- errorCode = 'api_deprecated';
62
-
63
- if (build) {
64
- message = build.message;
65
- logger.info(message);
66
- } else {
67
- message = Constants.userMessages.API_DEPRECATED;
68
- logger.info(message);
69
- }
70
- logger.info(utils.formatRequest(err, resp, body));
71
- } else if (resp.statusCode != 200) {
31
+ let options = {
32
+ url: config.buildUrl + buildId,
33
+ auth: {
34
+ user: bsConfig.auth.username,
35
+ password: bsConfig.auth.access_key,
36
+ },
37
+ headers: {
38
+ 'User-Agent': utils.getUserAgent(),
39
+ },
40
+ };
41
+ request.get(options, function (err, resp, body) {
42
+ let message = null;
43
+ let messageType = null;
44
+ let errorCode = null;
45
+
46
+ if (err) {
47
+ message = Constants.userMessages.BUILD_INFO_FAILED;
72
48
  messageType = Constants.messageTypes.ERROR;
73
49
  errorCode = 'api_failed_build_info';
74
-
75
- if (build) {
76
- message = `${
77
- Constants.userMessages.BUILD_INFO_FAILED
78
- } with error: \n${JSON.stringify(build, null, 2)}`;
79
- logger.error(message);
80
- if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
81
- } else {
82
- message = Constants.userMessages.BUILD_INFO_FAILED;
83
- logger.error(message);
84
- }
50
+
51
+ logger.info(message);
85
52
  logger.error(utils.formatRequest(err, resp, body));
86
53
  } else {
87
- messageType = Constants.messageTypes.SUCCESS;
88
- message = `Build info for build id: \n ${JSON.stringify(
89
- build,
90
- null,
91
- 2
92
- )}`;
93
- logger.info(message);
54
+ let build = null;
55
+ try {
56
+ build = JSON.parse(body);
57
+ } catch (error) {
58
+ build = null;
59
+ }
60
+
61
+ if (resp.statusCode == 299) {
62
+ messageType = Constants.messageTypes.INFO;
63
+ errorCode = 'api_deprecated';
64
+
65
+ if (build) {
66
+ message = build.message;
67
+ logger.info(message);
68
+ } else {
69
+ message = Constants.userMessages.API_DEPRECATED;
70
+ logger.info(message);
71
+ }
72
+ logger.info(utils.formatRequest(err, resp, body));
73
+ } else if (resp.statusCode != 200) {
74
+ messageType = Constants.messageTypes.ERROR;
75
+ errorCode = 'api_failed_build_info';
76
+
77
+ if (build) {
78
+ message = `${
79
+ Constants.userMessages.BUILD_INFO_FAILED
80
+ } with error: \n${JSON.stringify(build, null, 2)}`;
81
+ logger.error(message);
82
+ if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
83
+ } else {
84
+ message = Constants.userMessages.BUILD_INFO_FAILED;
85
+ logger.error(message);
86
+ }
87
+ logger.error(utils.formatRequest(err, resp, body));
88
+ } else {
89
+ messageType = Constants.messageTypes.SUCCESS;
90
+ message = `Build info for build id: \n ${JSON.stringify(
91
+ build,
92
+ null,
93
+ 2
94
+ )}`;
95
+ logger.info(message);
96
+ }
94
97
  }
95
- }
96
- utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
98
+ utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
99
+ });
100
+ }).catch((err) => {
101
+ logger.warn(err);
97
102
  });
98
103
  }).catch(function (err) {
99
104
  logger.error(err);
@@ -10,6 +10,7 @@ const archiver = require("../helpers/archiver"),
10
10
  Constants = require("../helpers/constants"),
11
11
  utils = require("../helpers/utils"),
12
12
  fileHelpers = require("../helpers/fileHelpers"),
13
+ getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails,
13
14
  syncRunner = require("../helpers/syncRunner"),
14
15
  checkUploaded = require("../helpers/checkUploaded"),
15
16
  packageInstaller = require("../helpers/packageInstaller"),
@@ -52,6 +53,8 @@ module.exports = function run(args, rawArgs) {
52
53
  // accept the access key from command line or env variable if provided
53
54
  utils.setAccessKey(bsConfig, args);
54
55
 
56
+ let buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
57
+
55
58
  // accept the build name from command line if provided
56
59
  utils.setBuildName(bsConfig, args);
57
60
 
@@ -128,7 +131,7 @@ module.exports = function run(args, rawArgs) {
128
131
  utils.setParallels(bsConfig, args, specFiles.length);
129
132
 
130
133
  // warn if specFiles cross our limit
131
- utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
134
+ utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs, buildReportData);
132
135
  markBlockEnd('preArchiveSteps');
133
136
  logger.debug("Completed pre-archive steps");
134
137
  markBlockStart('zip');
@@ -168,7 +171,7 @@ module.exports = function run(args, rawArgs) {
168
171
  //setup Local Testing
169
172
  markBlockStart('localSetup');
170
173
  logger.debug("Started setting up BrowserStack Local connection");
171
- let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs);
174
+ let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs, buildReportData);
172
175
  logger.debug('Completed setting up BrowserStack Local connection');
173
176
  markBlockEnd('localSetup');
174
177
  logger.debug("Started build creation");
@@ -177,14 +180,10 @@ module.exports = function run(args, rawArgs) {
177
180
  logger.debug("Completed build creation");
178
181
  markBlockEnd('createBuild');
179
182
  markBlockEnd('total');
180
- utils.setProcessHooks(data.build_id, bsConfig, bs_local, args);
183
+ utils.setProcessHooks(data.build_id, bsConfig, bs_local, args, buildReportData);
181
184
  let message = `${data.message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${data.build_id}`;
182
185
  let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${data.dashboard_url}`;
183
- let buildReportData = {
184
- 'build_id': data.build_id,
185
- 'user_id': data.user_id,
186
- 'parallels': userSpecifiedParallels
187
- };
186
+ buildReportData = { 'build_id': data.build_id, 'parallels': userSpecifiedParallels, ...buildReportData }
188
187
  utils.exportResults(data.build_id, `${config.dashboardUrl}${data.build_id}`);
189
188
  if ((utils.isUndefined(bsConfig.run_settings.parallels) && utils.isUndefined(args.parallels)) || (!utils.isUndefined(bsConfig.run_settings.parallels) && bsConfig.run_settings.parallels == Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE)) {
190
189
  logger.warn(Constants.userMessages.NO_PARALLELS);
@@ -208,11 +207,11 @@ module.exports = function run(args, rawArgs) {
208
207
 
209
208
  if (args.sync) {
210
209
  logger.debug("Started polling build status from BrowserStack");
211
- syncRunner.pollBuildStatus(bsConfig, data, rawArgs).then(async (exitCode) => {
210
+ syncRunner.pollBuildStatus(bsConfig, data, rawArgs, buildReportData).then(async (exitCode) => {
212
211
  logger.debug("Completed polling of build status");
213
212
 
214
213
  // stop the Local instance
215
- await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
214
+ await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
216
215
 
217
216
  // waiting for 5 secs for upload to complete (as a safety measure)
218
217
  await new Promise(resolve => setTimeout(resolve, 5000));
@@ -221,11 +220,11 @@ module.exports = function run(args, rawArgs) {
221
220
  if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
222
221
  if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
223
222
  logger.debug("Downloading build artifacts");
224
- await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
223
+ await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData);
225
224
  }
226
225
 
227
226
  // Generate custom report!
228
- reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
227
+ reportGenerator(bsConfig, data.build_id, args, rawArgs, buildReportData, function(){
229
228
  utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
230
229
  utils.handleSyncExit(exitCode, data.dashboard_url);
231
230
  });
@@ -299,24 +298,24 @@ module.exports = function run(args, rawArgs) {
299
298
  // Build creation failed
300
299
  logger.error(err);
301
300
  // stop the Local instance
302
- await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
301
+ await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
303
302
 
304
- utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'build_failed', null, rawArgs);
303
+ utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'build_failed', buildReportData, rawArgs);
305
304
  process.exitCode = Constants.ERROR_EXIT_CODE;
306
305
  });
307
306
  }).catch(function (err) {
308
307
  // Zip Upload failed | Local Start failed
309
308
  logger.error(err);
310
309
  if(err === Constants.userMessages.LOCAL_START_FAILED){
311
- utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.LOCAL_START_FAILED}`, Constants.messageTypes.ERROR, 'local_start_failed', null, rawArgs);
310
+ utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.LOCAL_START_FAILED}`, Constants.messageTypes.ERROR, 'local_start_failed', buildReportData, rawArgs);
312
311
  } else {
313
312
  logger.error(Constants.userMessages.ZIP_UPLOAD_FAILED);
314
313
  fileHelpers.deleteZip();
315
- utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.ZIP_UPLOAD_FAILED}`, Constants.messageTypes.ERROR, 'zip_upload_failed', null, rawArgs);
314
+ utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.ZIP_UPLOAD_FAILED}`, Constants.messageTypes.ERROR, 'zip_upload_failed', buildReportData, rawArgs);
316
315
  try {
317
316
  fileHelpers.deletePackageArchieve();
318
317
  } catch (err) {
319
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
318
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', buildReportData, rawArgs);
320
319
  }
321
320
  }
322
321
  process.exitCode = Constants.ERROR_EXIT_CODE;
@@ -325,16 +324,16 @@ module.exports = function run(args, rawArgs) {
325
324
  // Zipping failed
326
325
  logger.error(err);
327
326
  logger.error(Constants.userMessages.FAILED_TO_ZIP);
328
- utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.FAILED_TO_ZIP}`, Constants.messageTypes.ERROR, 'zip_creation_failed', null, rawArgs);
327
+ utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.FAILED_TO_ZIP}`, Constants.messageTypes.ERROR, 'zip_creation_failed', buildReportData, rawArgs);
329
328
  try {
330
329
  fileHelpers.deleteZip();
331
330
  } catch (err) {
332
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.ZIP_DELETE_FAILED, Constants.messageTypes.ERROR, 'zip_deletion_failed', null, rawArgs);
331
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.ZIP_DELETE_FAILED, Constants.messageTypes.ERROR, 'zip_deletion_failed', buildReportData, rawArgs);
333
332
  }
334
333
  try {
335
334
  fileHelpers.deletePackageArchieve();
336
335
  } catch (err) {
337
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
336
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', buildReportData, rawArgs);
338
337
  }
339
338
  process.exitCode = Constants.ERROR_EXIT_CODE;
340
339
  });
@@ -342,11 +341,11 @@ module.exports = function run(args, rawArgs) {
342
341
  // package installer failed
343
342
  logger.error(err);
344
343
  logger.error(Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE);
345
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE, Constants.messageTypes.ERROR, 'npm_package_archive_failed', null, rawArgs);
344
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE, Constants.messageTypes.ERROR, 'npm_package_archive_failed', buildReportData, rawArgs);
346
345
  try {
347
346
  fileHelpers.deletePackageArchieve();
348
347
  } catch (err) {
349
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
348
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', buildReportData, rawArgs);
350
349
  }
351
350
  process.exitCode = Constants.ERROR_EXIT_CODE;
352
351
  });
@@ -354,7 +353,7 @@ module.exports = function run(args, rawArgs) {
354
353
  // md5 check failed
355
354
  logger.error(err);
356
355
  logger.error(Constants.userMessages.FAILED_MD5_CHECK);
357
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.MD5_CHECK_FAILED, Constants.messageTypes.ERROR, 'zip_already_uploaded_failed', null, rawArgs);
356
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.MD5_CHECK_FAILED, Constants.messageTypes.ERROR, 'zip_already_uploaded_failed', buildReportData, rawArgs);
358
357
  process.exitCode = Constants.ERROR_EXIT_CODE;
359
358
  });
360
359
  }).catch(function (err) {
@@ -368,7 +367,7 @@ module.exports = function run(args, rawArgs) {
368
367
  }
369
368
 
370
369
  let error_code = utils.getErrorCodeFromMsg(err);
371
- utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.validationMessages.NOT_VALID}`, Constants.messageTypes.ERROR, error_code, null, rawArgs);
370
+ utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.validationMessages.NOT_VALID}`, Constants.messageTypes.ERROR, error_code, buildReportData, rawArgs);
372
371
  process.exitCode = Constants.ERROR_EXIT_CODE;
373
372
  });
374
373
  }).catch(function (err) {
@@ -4,7 +4,8 @@ const request = require('request');
4
4
  const config = require("../helpers/config"),
5
5
  logger = require("../helpers/logger").winstonLogger,
6
6
  Constants = require("../helpers/constants"),
7
- utils = require("../helpers/utils");
7
+ utils = require("../helpers/utils"),
8
+ getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails;
8
9
 
9
10
  module.exports = function stop(args, rawArgs) {
10
11
  let bsConfigPath = utils.getConfigPath(args.cf);
@@ -18,6 +19,8 @@ module.exports = function stop(args, rawArgs) {
18
19
  // accept the access key from command line if provided
19
20
  utils.setAccessKey(bsConfig, args);
20
21
 
22
+ let buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
23
+
21
24
  utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
22
25
 
23
26
  // set cypress config filename
@@ -25,7 +28,7 @@ module.exports = function stop(args, rawArgs) {
25
28
 
26
29
  let buildId = args._[1];
27
30
 
28
- await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
31
+ await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs, buildReportData);
29
32
 
30
33
  }).catch(function (err) {
31
34
  logger.error(err);
@@ -134,7 +134,7 @@ const unzipFile = async (filePath, fileName) => {
134
134
  });
135
135
  }
136
136
 
137
- const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) => {
137
+ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, buildReportData) => {
138
138
  options.url = `${config.buildUrl}${buildId}/build_artifacts/status`;
139
139
 
140
140
  let cypressJSON = utils.getCypressJSON(bsConfig);
@@ -161,7 +161,7 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) =>
161
161
  return new Promise (async (resolve, reject) => {
162
162
  request.post(options, function (err, resp, data) {
163
163
  if(err) {
164
- utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', null, rawArgs);
164
+ utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', buildReportData, rawArgs);
165
165
  logger.error(utils.formatRequest(err, resp, data));
166
166
  reject(err);
167
167
  } else {
@@ -172,7 +172,7 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) =>
172
172
  }
173
173
  if (resp.statusCode != 200) {
174
174
  if (responseData && responseData["error"]) {
175
- utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', null, rawArgs);
175
+ utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', buildReportData, rawArgs);
176
176
  reject(responseData["error"])
177
177
  }
178
178
  }
@@ -182,7 +182,7 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) =>
182
182
  });
183
183
  }
184
184
 
185
- exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
185
+ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildReportData = null) => {
186
186
  return new Promise ( async (resolve, reject) => {
187
187
  BUILD_ARTIFACTS_FAIL_COUNT = 0;
188
188
  BUILD_ARTIFACTS_TOTAL_COUNT = 0;
@@ -205,7 +205,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
205
205
  request.get(options, async function (err, resp, body) {
206
206
  if(err) {
207
207
  logger.error(utils.formatRequest(err, resp, body));
208
- utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
208
+ utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', buildReportData, rawArgs);
209
209
  process.exitCode = Constants.ERROR_EXIT_CODE;
210
210
  } else {
211
211
  try {
@@ -214,7 +214,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
214
214
  logger.error('Downloading the build artifacts failed.');
215
215
  logger.error(`Error: Request failed with status code ${resp.statusCode}`)
216
216
  logger.error(utils.formatRequest(err, resp, body));
217
- utils.sendUsageReport(bsConfig, args, buildDetails, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
217
+ utils.sendUsageReport(bsConfig, args, buildDetails, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', buildReportData, rawArgs);
218
218
  process.exitCode = Constants.ERROR_EXIT_CODE;
219
219
  } else {
220
220
  await createDirectories(buildId, buildDetails);
@@ -229,8 +229,8 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
229
229
  message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_SUCCESS.replace('<build-id>', buildId).replace('<user-path>', process.cwd());
230
230
  logger.info(message);
231
231
  }
232
- await sendUpdatesToBstack(bsConfig, buildId, args, options, rawArgs)
233
- utils.sendUsageReport(bsConfig, args, message, messageType, null, null, rawArgs);
232
+ await sendUpdatesToBstack(bsConfig, buildId, args, options, rawArgs, buildReportData)
233
+ utils.sendUsageReport(bsConfig, args, message, messageType, null, buildReportData, rawArgs);
234
234
  }
235
235
  } catch (err) {
236
236
  messageType = Constants.messageTypes.ERROR;
@@ -242,7 +242,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
242
242
  } else {
243
243
  logger.error('Downloading the build artifacts failed.');
244
244
  }
245
- utils.sendUsageReport(bsConfig, args, err, messageType, errorCode, null, rawArgs);
245
+ utils.sendUsageReport(bsConfig, args, err, messageType, errorCode, buildReportData, rawArgs);
246
246
  logger.error(`Error: Request failed with status code ${resp.statusCode}`)
247
247
  logger.error(utils.formatRequest(err, resp, body));
248
248
  process.exitCode = Constants.ERROR_EXIT_CODE;
@@ -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";
@@ -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
+ };
@@ -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;
@@ -23,14 +23,16 @@ let printSpecsRunSummary = (data, machines, customErrorsToPrint) => {
23
23
  total: 0,
24
24
  failed: 0,
25
25
  passed: 0,
26
- skipped: 0
26
+ skipped: 0,
27
+ passed_with_skipped: 0,
28
+ pending: 0
27
29
  };
28
30
 
29
31
  data.specs.forEach((spec) => {
30
32
  specSummaryCount(summary, spec.status.toLowerCase());
31
33
  });
32
34
 
33
- 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}`);
34
36
  logger.info(`Done in ${data.duration/1000} seconds using ${machines} machines\n`);
35
37
 
36
38
  if (customErrorsToPrint && customErrorsToPrint.length > 0) {
@@ -57,9 +59,15 @@ let specSummaryCount = (summary, status) => {
57
59
  case 'failed':
58
60
  summary.failed++;
59
61
  break;
62
+ case "passed_with_skipped":
63
+ summary.passed_with_skipped++;
64
+ break;
60
65
  case 'skipped':
61
66
  summary.skipped++;
62
67
  break;
68
+ case "pending":
69
+ summary.pending++;
70
+ break;
63
71
  case 'passed':
64
72
  summary.passed++;
65
73
  break;
@@ -96,7 +96,7 @@ let setNoWrapParams = () => {
96
96
  }
97
97
  };
98
98
 
99
- let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
99
+ let printSpecsStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
100
100
  setNoWrapParams();
101
101
  return new Promise((resolve, reject) => {
102
102
  options = getOptions(bsConfig.auth, buildDetails.build_id)
@@ -116,7 +116,7 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
116
116
  if(err.status == 204) {
117
117
  reject(specSummary.exitCode);
118
118
  } else {
119
- 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);
120
120
  }
121
121
  }
122
122
  logger.info(lineSeparator);
@@ -201,13 +201,14 @@ let printInitialLog = () => {
201
201
 
202
202
  let printSpecData = (data) => {
203
203
  let combination = getCombinationName(data["spec"]);
204
- let status = getStatus(data["spec"]["status"]);
205
- writeToTable(combination, data["path"], status)
206
- 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"])
207
208
  }
208
209
 
209
- let writeToTable = (combination, specName, status) => {
210
- stream.write([combination , ":", `${specName} ${status}`]);
210
+ let writeToTable = (combination, specName, status, statusMark) => {
211
+ stream.write([combination , ":", `${specName} ${statusMark} [${status}]`]);
211
212
  }
212
213
 
213
214
  let addCustomErrorToPrint = (error_object) => {
@@ -241,6 +242,8 @@ let getStatus = (status) => {
241
242
  return chalk.green("✔");
242
243
  case "failed":
243
244
  return chalk.red("✘");
245
+ case "passed_with_skipped":
246
+ return chalk.blueBright("✔");
244
247
  default:
245
248
  return chalk.blue(`[${status}]`);
246
249
  }
@@ -3,10 +3,10 @@ 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
7
  let customErrorsToPrint;
8
8
  return new Promise((resolve, reject) => {
9
- syncSpecsLogs.printSpecsStatus(bsConfig, buildDetails).then((data) => {
9
+ syncSpecsLogs.printSpecsStatus(bsConfig, buildDetails, rawArgs, buildReportData).then((data) => {
10
10
  if(data.customErrorsToPrint && data.customErrorsToPrint.length > 0) {
11
11
  customErrorsToPrint = data.customErrorsToPrint;
12
12
  }
@@ -182,7 +182,7 @@ exports.setParallels = (bsConfig, args, numOfSpecs) => {
182
182
  }
183
183
  };
184
184
 
185
- exports.warnSpecLimit = (bsConfig, args, specFiles, rawArgs) => {
185
+ exports.warnSpecLimit = (bsConfig, args, specFiles, rawArgs, buildReportData) => {
186
186
  let expectedCharLength = specFiles.join("").length + Constants.METADATA_CHAR_BUFFER_PER_SPEC * specFiles.length;
187
187
  let parallels = bsConfig.run_settings.parallels;
188
188
  let combinations = this.getBrowserCombinations(bsConfig).length;
@@ -196,7 +196,7 @@ exports.warnSpecLimit = (bsConfig, args, specFiles, rawArgs) => {
196
196
  Constants.userMessages.SPEC_LIMIT_WARNING,
197
197
  Constants.messageTypes.WARNING,
198
198
  null,
199
- null,
199
+ buildReportData,
200
200
  rawArgs
201
201
  );
202
202
  }
@@ -715,7 +715,7 @@ exports.setLocalMode = (bsConfig, args) => {
715
715
  }
716
716
  };
717
717
 
718
- exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
718
+ exports.setupLocalTesting = (bsConfig, args, rawArgs, buildReportData) => {
719
719
  return new Promise(async (resolve, reject) => {
720
720
  if( bsConfig['connection_settings'] && bsConfig['connection_settings']['local'] && String(bsConfig['connection_settings']['local']) === "true" ){
721
721
  let localBinaryRunning = await this.checkLocalBinaryRunning(bsConfig, bsConfig['connection_settings']['local_identifier']);
@@ -751,7 +751,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
751
751
  message,
752
752
  Constants.messageTypes.ERROR,
753
753
  errorCode,
754
- null,
754
+ buildReportData,
755
755
  rawArgs
756
756
  );
757
757
  reject(Constants.userMessages.LOCAL_START_FAILED);
@@ -766,7 +766,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
766
766
  });
767
767
  };
768
768
 
769
- exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
769
+ exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs, buildReportData) => {
770
770
  return new Promise(async (resolve, reject) => {
771
771
  if (!this.isUndefined(bs_local) && bs_local.isRunning() && bsConfig['connection_settings'] && bsConfig['connection_settings']['local_mode'].toLowerCase() != "always-on") {
772
772
  let that = this;
@@ -783,7 +783,7 @@ exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
783
783
  message,
784
784
  Constants.messageTypes.ERROR,
785
785
  errorCode,
786
- null,
786
+ buildReportData,
787
787
  rawArgs
788
788
  );
789
789
  resolve(Constants.userMessages.LOCAL_STOP_FAILED);
@@ -1089,7 +1089,7 @@ exports.setDebugMode = (args) => {
1089
1089
  }
1090
1090
 
1091
1091
 
1092
- exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
1092
+ exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs, buildReportData = null) => {
1093
1093
  let that = this;
1094
1094
  return new Promise(function (resolve, reject) {
1095
1095
  let url = config.buildStopUrl + buildId;
@@ -1152,7 +1152,7 @@ exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
1152
1152
  errorCode = 'api_failed_build_stop';
1153
1153
  logger.info(message);
1154
1154
  } finally {
1155
- that.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
1155
+ that.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
1156
1156
  }
1157
1157
  }
1158
1158
  resolve();
@@ -1160,12 +1160,13 @@ exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
1160
1160
  });
1161
1161
  }
1162
1162
 
1163
- exports.setProcessHooks = (buildId, bsConfig, bsLocal, args) => {
1163
+ exports.setProcessHooks = (buildId, bsConfig, bsLocal, args, buildReportData) => {
1164
1164
  let bindData = {
1165
1165
  buildId: buildId,
1166
1166
  bsConfig: bsConfig,
1167
1167
  bsLocalInstance: bsLocal,
1168
- args: args
1168
+ args: args,
1169
+ buildReportData: buildReportData
1169
1170
  }
1170
1171
  process.on('SIGINT', processExitHandler.bind(this, bindData));
1171
1172
  process.on('SIGTERM', processExitHandler.bind(this, bindData));
@@ -1175,8 +1176,8 @@ exports.setProcessHooks = (buildId, bsConfig, bsLocal, args) => {
1175
1176
 
1176
1177
  async function processExitHandler(exitData){
1177
1178
  logger.warn(Constants.userMessages.PROCESS_KILL_MESSAGE);
1178
- await this.stopBrowserStackBuild(exitData.bsConfig, exitData.args, exitData.buildId);
1179
- await this.stopLocalBinary(exitData.bsConfig, exitData.bsLocalInstance, exitData.args);
1179
+ await this.stopBrowserStackBuild(exitData.bsConfig, exitData.args, exitData.buildId, null, exitData.buildReportData);
1180
+ await this.stopLocalBinary(exitData.bsConfig, exitData.bsLocalInstance, exitData.args, null, exitData.buildReportData);
1180
1181
  process.exit(0);
1181
1182
  }
1182
1183
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "archiver": "5.3.0",
16
16
  "async": "3.2.3",
17
- "browserstack-local": "1.4.8",
17
+ "browserstack-local": "1.5.1",
18
18
  "chalk": "4.1.2",
19
19
  "cli-progress": "3.10.0",
20
20
  "fs-extra": "8.1.0",