browserstack-cypress-cli 1.13.1 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,12 @@ 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
+
100
+ // set node version
101
+ utils.setNodeVersion(bsConfig, args);
102
+
86
103
  //set browsers
87
104
  await utils.setBrowsers(bsConfig, args);
88
105
 
@@ -95,12 +112,16 @@ module.exports = function run(args, rawArgs) {
95
112
  // set other cypress configs e.g. reporter and reporter-options
96
113
  utils.setOtherConfigs(bsConfig, args);
97
114
  markBlockEnd('setConfig');
115
+ logger.debug("Completed setting the configs");
98
116
 
99
117
  // Validate browserstack.json values and parallels specified via arguments
100
118
  markBlockStart('validateConfig');
119
+ logger.debug("Started configs validation");
101
120
  return capabilityHelper.validate(bsConfig, args).then(function (cypressJson) {
102
121
  markBlockEnd('validateConfig');
122
+ logger.debug("Completed configs validation");
103
123
  markBlockStart('preArchiveSteps');
124
+ logger.debug("Started pre-archive steps");
104
125
  //get the number of spec files
105
126
  let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressJson);
106
127
 
@@ -113,48 +134,59 @@ module.exports = function run(args, rawArgs) {
113
134
  utils.setParallels(bsConfig, args, specFiles.length);
114
135
 
115
136
  // warn if specFiles cross our limit
116
- utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
137
+ utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs, buildReportData);
117
138
  markBlockEnd('preArchiveSteps');
139
+ logger.debug("Completed pre-archive steps");
118
140
  markBlockStart('zip');
141
+ logger.debug("Checking if test suite zip and dependencies is already available on browserstack");
119
142
  markBlockStart('zip.checkAlreadyUploaded');
120
143
  return checkUploaded.checkUploadedMd5(bsConfig, args, {markBlockStart, markBlockEnd}).then(function (md5data) {
121
144
  markBlockEnd('zip.checkAlreadyUploaded');
145
+ logger.debug("Completed checking if test suite zip and dependencies already uploaded");
122
146
 
147
+ logger.debug("Started caching npm dependencies.");
123
148
  markBlockStart('zip.packageInstaller');
124
149
  return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
150
+ logger.debug("Completed caching npm dependencies.")
125
151
  markBlockEnd('zip.packageInstaller');
126
152
 
127
153
  // Archive the spec files
154
+ logger.debug("Started archiving test suite");
128
155
  markBlockStart('zip.archive');
129
156
  return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(function (data) {
157
+ logger.debug("Completed archiving test suite");
130
158
  markBlockEnd('zip.archive');
131
159
 
132
160
  let test_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.fileName));
133
161
  let npm_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.packageFileName));
134
162
 
135
163
  // Uploaded zip file
164
+ logger.debug("Started uploading the test suite zip");
165
+ logger.debug("Started uploading the node_module zip");
136
166
  markBlockStart('zip.zipUpload');
137
167
  return zipUploader.zipUpload(bsConfig, md5data, packageData).then(async function (zip) {
168
+ logger.debug("Completed uploading the test suite zip");
169
+ logger.debug("Completed uploading the node_module zip");
138
170
  markBlockEnd('zip.zipUpload');
139
171
  markBlockEnd('zip');
140
172
 
141
173
  // Create build
142
174
  //setup Local Testing
143
175
  markBlockStart('localSetup');
144
- let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs);
176
+ logger.debug("Started setting up BrowserStack Local connection");
177
+ let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs, buildReportData);
178
+ logger.debug('Completed setting up BrowserStack Local connection');
145
179
  markBlockEnd('localSetup');
180
+ logger.debug("Started build creation");
146
181
  markBlockStart('createBuild');
147
182
  return build.createBuild(bsConfig, zip).then(function (data) {
183
+ logger.debug("Completed build creation");
148
184
  markBlockEnd('createBuild');
149
185
  markBlockEnd('total');
150
- utils.setProcessHooks(data.build_id, bsConfig, bs_local, args);
186
+ utils.setProcessHooks(data.build_id, bsConfig, bs_local, args, buildReportData);
151
187
  let message = `${data.message}! ${Constants.userMessages.BUILD_CREATED} with build id: ${data.build_id}`;
152
188
  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
- };
189
+ buildReportData = { 'build_id': data.build_id, 'parallels': userSpecifiedParallels, ...buildReportData }
158
190
  utils.exportResults(data.build_id, `${config.dashboardUrl}${data.build_id}`);
159
191
  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
192
  logger.warn(Constants.userMessages.NO_PARALLELS);
@@ -177,10 +209,12 @@ module.exports = function run(args, rawArgs) {
177
209
 
178
210
 
179
211
  if (args.sync) {
180
- syncRunner.pollBuildStatus(bsConfig, data, rawArgs).then(async (exitCode) => {
212
+ logger.debug("Started polling build status from BrowserStack");
213
+ syncRunner.pollBuildStatus(bsConfig, data, rawArgs, buildReportData).then(async (exitCode) => {
214
+ logger.debug("Completed polling of build status");
181
215
 
182
216
  // stop the Local instance
183
- await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
217
+ await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
184
218
 
185
219
  // waiting for 5 secs for upload to complete (as a safety measure)
186
220
  await new Promise(resolve => setTimeout(resolve, 5000));
@@ -188,11 +222,12 @@ module.exports = function run(args, rawArgs) {
188
222
  // download build artifacts
189
223
  if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
190
224
  if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
191
- await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
225
+ logger.debug("Downloading build artifacts");
226
+ await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData);
192
227
  }
193
228
 
194
229
  // Generate custom report!
195
- reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
230
+ reportGenerator(bsConfig, data.build_id, args, rawArgs, buildReportData, function(){
196
231
  utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
197
232
  utils.handleSyncExit(exitCode, data.dashboard_url);
198
233
  });
@@ -266,24 +301,24 @@ module.exports = function run(args, rawArgs) {
266
301
  // Build creation failed
267
302
  logger.error(err);
268
303
  // stop the Local instance
269
- await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
304
+ await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
270
305
 
271
- utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'build_failed', null, rawArgs);
306
+ utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'build_failed', buildReportData, rawArgs);
272
307
  process.exitCode = Constants.ERROR_EXIT_CODE;
273
308
  });
274
309
  }).catch(function (err) {
275
310
  // Zip Upload failed | Local Start failed
276
311
  logger.error(err);
277
312
  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);
313
+ utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.LOCAL_START_FAILED}`, Constants.messageTypes.ERROR, 'local_start_failed', buildReportData, rawArgs);
279
314
  } else {
280
315
  logger.error(Constants.userMessages.ZIP_UPLOAD_FAILED);
281
316
  fileHelpers.deleteZip();
282
- utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.ZIP_UPLOAD_FAILED}`, Constants.messageTypes.ERROR, 'zip_upload_failed', null, rawArgs);
317
+ utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.ZIP_UPLOAD_FAILED}`, Constants.messageTypes.ERROR, 'zip_upload_failed', buildReportData, rawArgs);
283
318
  try {
284
319
  fileHelpers.deletePackageArchieve();
285
320
  } catch (err) {
286
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
321
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', buildReportData, rawArgs);
287
322
  }
288
323
  }
289
324
  process.exitCode = Constants.ERROR_EXIT_CODE;
@@ -292,16 +327,16 @@ module.exports = function run(args, rawArgs) {
292
327
  // Zipping failed
293
328
  logger.error(err);
294
329
  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);
330
+ utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.FAILED_TO_ZIP}`, Constants.messageTypes.ERROR, 'zip_creation_failed', buildReportData, rawArgs);
296
331
  try {
297
332
  fileHelpers.deleteZip();
298
333
  } catch (err) {
299
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.ZIP_DELETE_FAILED, Constants.messageTypes.ERROR, 'zip_deletion_failed', null, rawArgs);
334
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.ZIP_DELETE_FAILED, Constants.messageTypes.ERROR, 'zip_deletion_failed', buildReportData, rawArgs);
300
335
  }
301
336
  try {
302
337
  fileHelpers.deletePackageArchieve();
303
338
  } catch (err) {
304
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
339
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', buildReportData, rawArgs);
305
340
  }
306
341
  process.exitCode = Constants.ERROR_EXIT_CODE;
307
342
  });
@@ -309,11 +344,11 @@ module.exports = function run(args, rawArgs) {
309
344
  // package installer failed
310
345
  logger.error(err);
311
346
  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);
347
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.FAILED_CREATE_NPM_ARCHIVE, Constants.messageTypes.ERROR, 'npm_package_archive_failed', buildReportData, rawArgs);
313
348
  try {
314
349
  fileHelpers.deletePackageArchieve();
315
350
  } catch (err) {
316
- utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', null, rawArgs);
351
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.NPM_DELETE_FAILED, Constants.messageTypes.ERROR, 'npm_deletion_failed', buildReportData, rawArgs);
317
352
  }
318
353
  process.exitCode = Constants.ERROR_EXIT_CODE;
319
354
  });
@@ -321,7 +356,7 @@ module.exports = function run(args, rawArgs) {
321
356
  // md5 check failed
322
357
  logger.error(err);
323
358
  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);
359
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.MD5_CHECK_FAILED, Constants.messageTypes.ERROR, 'zip_already_uploaded_failed', buildReportData, rawArgs);
325
360
  process.exitCode = Constants.ERROR_EXIT_CODE;
326
361
  });
327
362
  }).catch(function (err) {
@@ -335,7 +370,7 @@ module.exports = function run(args, rawArgs) {
335
370
  }
336
371
 
337
372
  let error_code = utils.getErrorCodeFromMsg(err);
338
- utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.validationMessages.NOT_VALID}`, Constants.messageTypes.ERROR, error_code, null, rawArgs);
373
+ utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.validationMessages.NOT_VALID}`, Constants.messageTypes.ERROR, error_code, buildReportData, rawArgs);
339
374
  process.exitCode = Constants.ERROR_EXIT_CODE;
340
375
  });
341
376
  }).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,18 @@ 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
+
257
+ if (!Utils.isUndefined(bsConfig.run_settings.nodeVersion) && typeof(bsConfig.run_settings.nodeVersion) === 'string' && !bsConfig.run_settings.nodeVersion.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/))
258
+ logger.warn(Constants.validationMessages.NODE_VERSION_PARSING_ERROR);
259
+
244
260
  resolve(cypressJson);
245
261
  });
246
262
  }