browserstack-cypress-cli 1.13.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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"),
@@ -22,7 +23,12 @@ const archiver = require("../helpers/archiver"),
22
23
  const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
23
24
 
24
25
  module.exports = function run(args, rawArgs) {
26
+
27
+ // set debug mode (--cli-debug)
28
+ utils.setDebugMode(args);
29
+
25
30
  let bsConfigPath = utils.getConfigPath(args.cf);
31
+ logger.debug(`browserstack.json path : ${bsConfigPath}`);
26
32
  //Delete build_results.txt from log folder if already present.
27
33
  initTimeComponents();
28
34
  instrumentEventTime("cliStart")
@@ -31,9 +37,12 @@ module.exports = function run(args, rawArgs) {
31
37
  markBlockEnd('deleteOldResults');
32
38
 
33
39
  markBlockStart('validateBstackJson');
40
+ logger.debug('Started browserstack.json validation');
34
41
  return utils.validateBstackJson(bsConfigPath).then(async function (bsConfig) {
35
42
  markBlockEnd('validateBstackJson');
43
+ logger.debug('Completed browserstack.json validation');
36
44
  markBlockStart('setConfig');
45
+ logger.debug('Started setting the configs');
37
46
  utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
38
47
 
39
48
  utils.setDefaults(bsConfig, args);
@@ -44,6 +53,8 @@ module.exports = function run(args, rawArgs) {
44
53
  // accept the access key from command line or env variable if provided
45
54
  utils.setAccessKey(bsConfig, args);
46
55
 
56
+ let buildReportData = await getInitialDetails(bsConfig, args, rawArgs);
57
+
47
58
  // accept the build name from command line if provided
48
59
  utils.setBuildName(bsConfig, args);
49
60
 
@@ -83,6 +94,9 @@ module.exports = function run(args, rawArgs) {
83
94
  // set the no-wrap
84
95
  utils.setNoWrap(bsConfig, args);
85
96
 
97
+ // set record feature caps
98
+ utils.setRecordCaps(bsConfig, args);
99
+
86
100
  //set browsers
87
101
  await utils.setBrowsers(bsConfig, args);
88
102
 
@@ -95,12 +109,16 @@ module.exports = function run(args, rawArgs) {
95
109
  // set other cypress configs e.g. reporter and reporter-options
96
110
  utils.setOtherConfigs(bsConfig, args);
97
111
  markBlockEnd('setConfig');
112
+ logger.debug("Completed setting the configs");
98
113
 
99
114
  // Validate browserstack.json values and parallels specified via arguments
100
115
  markBlockStart('validateConfig');
116
+ logger.debug("Started configs validation");
101
117
  return capabilityHelper.validate(bsConfig, args).then(function (cypressJson) {
102
118
  markBlockEnd('validateConfig');
119
+ logger.debug("Completed configs validation");
103
120
  markBlockStart('preArchiveSteps');
121
+ logger.debug("Started pre-archive steps");
104
122
  //get the number of spec files
105
123
  let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressJson);
106
124
 
@@ -113,48 +131,59 @@ module.exports = function run(args, rawArgs) {
113
131
  utils.setParallels(bsConfig, args, specFiles.length);
114
132
 
115
133
  // warn if specFiles cross our limit
116
- utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
134
+ utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs, buildReportData);
117
135
  markBlockEnd('preArchiveSteps');
136
+ logger.debug("Completed pre-archive steps");
118
137
  markBlockStart('zip');
138
+ logger.debug("Checking if test suite zip and dependencies is already available on browserstack");
119
139
  markBlockStart('zip.checkAlreadyUploaded');
120
140
  return checkUploaded.checkUploadedMd5(bsConfig, args, {markBlockStart, markBlockEnd}).then(function (md5data) {
121
141
  markBlockEnd('zip.checkAlreadyUploaded');
142
+ logger.debug("Completed checking if test suite zip and dependencies already uploaded");
122
143
 
144
+ logger.debug("Started caching npm dependencies.");
123
145
  markBlockStart('zip.packageInstaller');
124
146
  return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
147
+ logger.debug("Completed caching npm dependencies.")
125
148
  markBlockEnd('zip.packageInstaller');
126
149
 
127
150
  // Archive the spec files
151
+ logger.debug("Started archiving test suite");
128
152
  markBlockStart('zip.archive');
129
153
  return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(function (data) {
154
+ logger.debug("Completed archiving test suite");
130
155
  markBlockEnd('zip.archive');
131
156
 
132
157
  let test_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.fileName));
133
158
  let npm_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.packageFileName));
134
159
 
135
160
  // Uploaded zip file
161
+ logger.debug("Started uploading the test suite zip");
162
+ logger.debug("Started uploading the node_module zip");
136
163
  markBlockStart('zip.zipUpload');
137
164
  return zipUploader.zipUpload(bsConfig, md5data, packageData).then(async function (zip) {
165
+ logger.debug("Completed uploading the test suite zip");
166
+ logger.debug("Completed uploading the node_module zip");
138
167
  markBlockEnd('zip.zipUpload');
139
168
  markBlockEnd('zip');
140
169
 
141
170
  // Create build
142
171
  //setup Local Testing
143
172
  markBlockStart('localSetup');
144
- let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs);
173
+ logger.debug("Started setting up BrowserStack Local connection");
174
+ let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs, buildReportData);
175
+ logger.debug('Completed setting up BrowserStack Local connection');
145
176
  markBlockEnd('localSetup');
177
+ logger.debug("Started build creation");
146
178
  markBlockStart('createBuild');
147
179
  return build.createBuild(bsConfig, zip).then(function (data) {
180
+ logger.debug("Completed build creation");
148
181
  markBlockEnd('createBuild');
149
182
  markBlockEnd('total');
150
- utils.setProcessHooks(data.build_id, bsConfig, bs_local, args);
183
+ utils.setProcessHooks(data.build_id, bsConfig, bs_local, args, buildReportData);
151
184
  let message = `${data.message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${data.build_id}`;
152
185
  let dashboardLink = `${Constants.userMessages.VISIT_DASHBOARD} ${data.dashboard_url}`;
153
- let buildReportData = {
154
- 'build_id': data.build_id,
155
- 'user_id': data.user_id,
156
- 'parallels': userSpecifiedParallels
157
- };
186
+ buildReportData = { 'build_id': data.build_id, 'parallels': userSpecifiedParallels, ...buildReportData }
158
187
  utils.exportResults(data.build_id, `${config.dashboardUrl}${data.build_id}`);
159
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)) {
160
189
  logger.warn(Constants.userMessages.NO_PARALLELS);
@@ -177,10 +206,12 @@ module.exports = function run(args, rawArgs) {
177
206
 
178
207
 
179
208
  if (args.sync) {
180
- syncRunner.pollBuildStatus(bsConfig, data, rawArgs).then(async (exitCode) => {
209
+ logger.debug("Started polling build status from BrowserStack");
210
+ syncRunner.pollBuildStatus(bsConfig, data, rawArgs, buildReportData).then(async (exitCode) => {
211
+ logger.debug("Completed polling of build status");
181
212
 
182
213
  // stop the Local instance
183
- await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
214
+ await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
184
215
 
185
216
  // waiting for 5 secs for upload to complete (as a safety measure)
186
217
  await new Promise(resolve => setTimeout(resolve, 5000));
@@ -188,11 +219,12 @@ module.exports = function run(args, rawArgs) {
188
219
  // download build artifacts
189
220
  if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
190
221
  if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
191
- await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
222
+ logger.debug("Downloading build artifacts");
223
+ await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData);
192
224
  }
193
225
 
194
226
  // Generate custom report!
195
- reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
227
+ reportGenerator(bsConfig, data.build_id, args, rawArgs, buildReportData, function(){
196
228
  utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
197
229
  utils.handleSyncExit(exitCode, data.dashboard_url);
198
230
  });
@@ -266,24 +298,24 @@ module.exports = function run(args, rawArgs) {
266
298
  // Build creation failed
267
299
  logger.error(err);
268
300
  // stop the Local instance
269
- await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
301
+ await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
270
302
 
271
- 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);
272
304
  process.exitCode = Constants.ERROR_EXIT_CODE;
273
305
  });
274
306
  }).catch(function (err) {
275
307
  // Zip Upload failed | Local Start failed
276
308
  logger.error(err);
277
309
  if(err === Constants.userMessages.LOCAL_START_FAILED){
278
- 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);
279
311
  } else {
280
312
  logger.error(Constants.userMessages.ZIP_UPLOAD_FAILED);
281
313
  fileHelpers.deleteZip();
282
- 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);
283
315
  try {
284
316
  fileHelpers.deletePackageArchieve();
285
317
  } catch (err) {
286
- 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);
287
319
  }
288
320
  }
289
321
  process.exitCode = Constants.ERROR_EXIT_CODE;
@@ -292,16 +324,16 @@ module.exports = function run(args, rawArgs) {
292
324
  // Zipping failed
293
325
  logger.error(err);
294
326
  logger.error(Constants.userMessages.FAILED_TO_ZIP);
295
- 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);
296
328
  try {
297
329
  fileHelpers.deleteZip();
298
330
  } catch (err) {
299
- 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);
300
332
  }
301
333
  try {
302
334
  fileHelpers.deletePackageArchieve();
303
335
  } catch (err) {
304
- 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);
305
337
  }
306
338
  process.exitCode = Constants.ERROR_EXIT_CODE;
307
339
  });
@@ -309,11 +341,11 @@ module.exports = function run(args, rawArgs) {
309
341
  // package installer failed
310
342
  logger.error(err);
311
343
  logger.error(Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE);
312
- 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);
313
345
  try {
314
346
  fileHelpers.deletePackageArchieve();
315
347
  } catch (err) {
316
- 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);
317
349
  }
318
350
  process.exitCode = Constants.ERROR_EXIT_CODE;
319
351
  });
@@ -321,7 +353,7 @@ module.exports = function run(args, rawArgs) {
321
353
  // md5 check failed
322
354
  logger.error(err);
323
355
  logger.error(Constants.userMessages.FAILED_MD5_CHECK);
324
- 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);
325
357
  process.exitCode = Constants.ERROR_EXIT_CODE;
326
358
  });
327
359
  }).catch(function (err) {
@@ -335,7 +367,7 @@ module.exports = function run(args, rawArgs) {
335
367
  }
336
368
 
337
369
  let error_code = utils.getErrorCodeFromMsg(err);
338
- 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);
339
371
  process.exitCode = Constants.ERROR_EXIT_CODE;
340
372
  });
341
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);
@@ -10,6 +10,7 @@ const archiver = require("archiver"),
10
10
  const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
11
11
  return new Promise(function (resolve, reject) {
12
12
  if (md5data.zipUrlPresent) {
13
+ logger.debug("Skipping test suite upload since BrowserStack already has your test suite that has not changed since the last run.");
13
14
  return resolve('Zipping not required');
14
15
  }
15
16
  var output = fs.createWriteStream(filePath);
@@ -55,6 +56,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
55
56
  archive.pipe(output);
56
57
 
57
58
  let ignoreFiles = utils.getFilesToIgnore(runSettings, excludeFiles);
59
+ logger.debug(`Patterns ignored during zip ${ignoreFiles}`);
58
60
  archive.glob(`**/*.+(${Constants.allowedFileTypes.join("|")})`, { cwd: cypressFolderPath, matchBase: true, ignore: ignoreFiles, dot:true });
59
61
 
60
62
  let packageJSON = {};
@@ -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,8 +161,8 @@ 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);
165
- logger.error(utils.formatRequest(err, resp, body));
164
+ utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', buildReportData, rawArgs);
165
+ logger.error(utils.formatRequest(err, resp, data));
166
166
  reject(err);
167
167
  } else {
168
168
  try {
@@ -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;
@@ -146,6 +146,7 @@ const addCypressZipStartLocation = (runSettings) => {
146
146
  let resolvedCypressConfigFilePath = path.resolve(runSettings.cypressConfigFilePath);
147
147
  runSettings.cypressZipStartLocation = path.dirname(resolvedCypressConfigFilePath.split(resolvedHomeDirectoryPath)[1]);
148
148
  runSettings.cypressZipStartLocation = runSettings.cypressZipStartLocation.substring(1);
149
+ logger.debug(`Setting cypress zip start location = ${runSettings.cypressZipStartLocation}`);
149
150
  }
150
151
 
151
152
  const validate = (bsConfig, args) => {
@@ -190,8 +191,10 @@ const validate = (bsConfig, args) => {
190
191
  let cypressConfigFilePath = bsConfig.run_settings.cypressConfigFilePath;
191
192
  let cypressJson = {};
192
193
 
194
+ logger.debug(`Checking for cypress config file at ${cypressConfigFilePath}`);
193
195
  if (!fs.existsSync(cypressConfigFilePath) && bsConfig.run_settings.cypress_config_filename !== 'false') reject(Constants.validationMessages.INVALID_CYPRESS_CONFIG_FILE);
194
196
 
197
+ logger.debug("Validating cypress.json");
195
198
  try {
196
199
  if (bsConfig.run_settings.cypress_config_filename !== 'false') {
197
200
  let cypressJsonContent = fs.readFileSync(cypressConfigFilePath);
@@ -210,6 +213,7 @@ const validate = (bsConfig, args) => {
210
213
  //check if home_directory is present or not in user run_settings
211
214
  if (!Utils.isUndefined(bsConfig.run_settings.home_directory)) {
212
215
  // check if home_directory exists or not
216
+ logger.debug(`Validating home_directory at ${bsConfig.run_settings.home_directory}`);
213
217
  if (!fs.existsSync(bsConfig.run_settings.home_directory)) {
214
218
  reject(Constants.validationMessages.HOME_DIRECTORY_NOT_FOUND);
215
219
  }
@@ -241,6 +245,15 @@ const validate = (bsConfig, args) => {
241
245
  logger.warn(Constants.validationMessages.SPEC_TIMEOUT_NOT_PASSED_ERROR);
242
246
  }
243
247
 
248
+ if(!Utils.isUndefined(bsConfig.run_settings["record"]) && String(bsConfig.run_settings["record"]) == 'true') {
249
+ if(Utils.isUndefined(bsConfig.run_settings.projectId) || bsConfig.run_settings.projectId == "" ) {
250
+ logger.warn(Constants.validationMessages.PROJECT_ID_MISSING);
251
+ }
252
+ if (Utils.isUndefined(bsConfig.run_settings["record-key"]) || bsConfig.run_settings["record-key"] == "" ) {
253
+ logger.warn(Constants.validationMessages.RECORD_KEY_MISSING);
254
+ }
255
+ }
256
+
244
257
  resolve(cypressJson);
245
258
  });
246
259
  }