browserstack-cypress-cli 1.31.5 → 1.31.6

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.
@@ -9,6 +9,8 @@ const { promisify } = require('util');
9
9
  const gitconfig = require('gitconfiglocal');
10
10
  const { spawn, execSync } = require('child_process');
11
11
  const glob = require('glob');
12
+ const util = require('util');
13
+
12
14
  const { runOptions } = require('../../helpers/runnerArgs')
13
15
 
14
16
  const pGitconfig = promisify(gitconfig);
@@ -38,6 +40,13 @@ exports.pending_test_uploads = {
38
40
  count: 0
39
41
  };
40
42
 
43
+ exports.debugOnConsole = (text) => {
44
+ if ((process.env.BROWSERSTACK_OBSERVABILITY_DEBUG + '') === "true" ||
45
+ (process.env.BROWSERSTACK_OBSERVABILITY_DEBUG + '') === "1") {
46
+ consoleHolder.log(`[ OBSERVABILITY ] ${text}`);
47
+ }
48
+ }
49
+
41
50
  exports.debug = (text, shouldReport = false, throwable = null) => {
42
51
  if (process.env.BROWSERSTACK_OBSERVABILITY_DEBUG === "true" || process.env.BROWSERSTACK_OBSERVABILITY_DEBUG === "1") {
43
52
  logger.info(`[ OBSERVABILITY ] ${text}`);
@@ -475,7 +484,10 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => {
475
484
  };
476
485
 
477
486
  try {
487
+ const eventsUuids = data.map(eventData => `${eventData.event_type}:${eventData.test_run ? eventData.test_run.uuid : (eventData.hook_run ? eventData.hook_run.uuid : null)}`).join(', ');
488
+ exports.debugOnConsole(`[Request Batch Send] for events:uuids ${eventsUuids}`);
478
489
  const response = await nodeRequest('POST',eventUrl,data,config);
490
+ exports.debugOnConsole(`[Request Batch Response] for events:uuids ${eventsUuids}`);
479
491
  if(response.data.error) {
480
492
  throw({message: response.data.error});
481
493
  } else {
@@ -483,6 +495,7 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => {
483
495
  exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count - data.length);
484
496
  }
485
497
  } catch(error) {
498
+ exports.debugOnConsole(`[Request Error] Error in sending request ${util.format(error)}`);
486
499
  if (error.response) {
487
500
  exports.debug(`EXCEPTION IN ${kind} REQUEST TO TEST OBSERVABILITY : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error);
488
501
  } else {
@@ -496,6 +509,7 @@ const RequestQueueHandler = require('./requestQueueHandler');
496
509
  exports.requestQueueHandler = new RequestQueueHandler();
497
510
 
498
511
  exports.uploadEventData = async (eventData, run=0) => {
512
+ exports.debugOnConsole(`[uploadEventData] ${eventData.event_type}`);
499
513
  const log_tag = {
500
514
  ['TestRunStarted']: 'Test_Start_Upload',
501
515
  ['TestRunFinished']: 'Test_End_Upload',
@@ -522,6 +536,7 @@ exports.uploadEventData = async (eventData, run=0) => {
522
536
 
523
537
  exports.requestQueueHandler.start();
524
538
  const { shouldProceed, proceedWithData, proceedWithUrl } = exports.requestQueueHandler.add(eventData);
539
+ exports.debugOnConsole(`[Request Queue] ${eventData.event_type} with uuid ${eventData.test_run ? eventData.test_run.uuid : (eventData.hook_run ? eventData.hook_run.uuid : null)} is added`)
525
540
  if(!shouldProceed) {
526
541
  return;
527
542
  } else if(proceedWithData) {
@@ -538,7 +553,10 @@ exports.uploadEventData = async (eventData, run=0) => {
538
553
  };
539
554
 
540
555
  try {
556
+ const eventsUuids = data.map(eventData => `${eventData.event_type}:${eventData.test_run ? eventData.test_run.uuid : (eventData.hook_run ? eventData.hook_run.uuid : null)}`).join(', ');
557
+ exports.debugOnConsole(`[Request Send] for events:uuids ${eventsUuids}`);
541
558
  const response = await nodeRequest('POST',event_api_url,data,config);
559
+ exports.debugOnConsole(`[Request Repsonse] ${util.format(response.data)} for events:uuids ${eventsUuids}`)
542
560
  if(response.data.error) {
543
561
  throw({message: response.data.error});
544
562
  } else {
@@ -550,6 +568,7 @@ exports.uploadEventData = async (eventData, run=0) => {
550
568
  };
551
569
  }
552
570
  } catch(error) {
571
+ exports.debugOnConsole(`[Request Error] Error in sending request ${util.format(error)}`);
553
572
  if (error.response) {
554
573
  exports.debug(`EXCEPTION IN ${event_api_url !== exports.requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO TEST OBSERVABILITY : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error);
555
574
  } else {
@@ -57,7 +57,8 @@ const {
57
57
  getOSDetailsFromSystem,
58
58
  findGitConfig,
59
59
  getFileSeparatorData,
60
- setCrashReportingConfigFromReporter
60
+ setCrashReportingConfigFromReporter,
61
+ debugOnConsole
61
62
  } = require('../helper/helper');
62
63
 
63
64
  const { consoleHolder } = require('../helper/constants');
@@ -87,6 +88,7 @@ class MyReporter {
87
88
  })
88
89
 
89
90
  .on(EVENT_HOOK_BEGIN, async (hook) => {
91
+ debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_BEGIN`);
90
92
  if(this.testObservability == true) {
91
93
  if(!hook.hookAnalyticsId) {
92
94
  hook.hookAnalyticsId = uuidv4();
@@ -94,6 +96,7 @@ class MyReporter {
94
96
  delete this.runStatusMarkedHash[hook.hookAnalyticsId];
95
97
  hook.hookAnalyticsId = uuidv4();
96
98
  }
99
+ debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_BEGIN for uuid: ${hook.hookAnalyticsId}`);
97
100
  hook.hook_started_at = (new Date()).toISOString();
98
101
  hook.started_at = (new Date()).toISOString();
99
102
  this.current_hook = hook;
@@ -102,6 +105,7 @@ class MyReporter {
102
105
  })
103
106
 
104
107
  .on(EVENT_HOOK_END, async (hook) => {
108
+ debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_END`);
105
109
  if(this.testObservability == true) {
106
110
  if(!this.runStatusMarkedHash[hook.hookAnalyticsId]) {
107
111
  if(!hook.hookAnalyticsId) {
@@ -114,6 +118,9 @@ class MyReporter {
114
118
 
115
119
  // Remove hooks added at hook start
116
120
  delete this.hooksStarted[hook.hookAnalyticsId];
121
+
122
+ debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_END for uuid: ${hook.hookAnalyticsId}`);
123
+
117
124
  await this.sendTestRunEvent(hook,undefined,false,"HookRunFinished");
118
125
  }
119
126
  }
@@ -123,7 +130,9 @@ class MyReporter {
123
130
  })
124
131
 
125
132
  .on(EVENT_TEST_PASS, async (test) => {
133
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_PASS`);
126
134
  if(this.testObservability == true) {
135
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_PASS for uuid: ${test.testAnalyticsId}`);
127
136
  if(!this.runStatusMarkedHash[test.testAnalyticsId]) {
128
137
  if(test.testAnalyticsId) this.runStatusMarkedHash[test.testAnalyticsId] = true;
129
138
  await this.sendTestRunEvent(test);
@@ -132,7 +141,9 @@ class MyReporter {
132
141
  })
133
142
 
134
143
  .on(EVENT_TEST_FAIL, async (test, err) => {
144
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_FAIL`);
135
145
  if(this.testObservability == true) {
146
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_FAIL for uuid: ${test.testAnalyticsId}`);
136
147
  if((test.testAnalyticsId && !this.runStatusMarkedHash[test.testAnalyticsId]) || (test.hookAnalyticsId && !this.runStatusMarkedHash[test.hookAnalyticsId])) {
137
148
  if(test.testAnalyticsId) {
138
149
  this.runStatusMarkedHash[test.testAnalyticsId] = true;
@@ -146,8 +157,10 @@ class MyReporter {
146
157
  })
147
158
 
148
159
  .on(EVENT_TEST_PENDING, async (test) => {
160
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_PENDING`);
149
161
  if(this.testObservability == true) {
150
162
  if(!test.testAnalyticsId) test.testAnalyticsId = uuidv4();
163
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_PENDING for uuid: ${test.testAnalyticsId}`);
151
164
  if(!this.runStatusMarkedHash[test.testAnalyticsId]) {
152
165
  this.runStatusMarkedHash[test.testAnalyticsId] = true;
153
166
  await this.sendTestRunEvent(test,undefined,false,"TestRunSkipped");
@@ -156,6 +169,8 @@ class MyReporter {
156
169
  })
157
170
 
158
171
  .on(EVENT_TEST_BEGIN, async (test) => {
172
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_BEGIN`);
173
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`);
159
174
  if (this.runStatusMarkedHash[test.testAnalyticsId]) return;
160
175
  if(this.testObservability == true) {
161
176
  await this.testStarted(test);
@@ -163,6 +178,8 @@ class MyReporter {
163
178
  })
164
179
 
165
180
  .on(EVENT_TEST_END, async (test) => {
181
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_END`);
182
+ debugOnConsole(`[MOCHA EVENT] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`);
166
183
  if (this.runStatusMarkedHash[test.testAnalyticsId]) return;
167
184
  if(this.testObservability == true) {
168
185
  if(!this.runStatusMarkedHash[test.testAnalyticsId]) {
@@ -174,10 +191,12 @@ class MyReporter {
174
191
 
175
192
  .once(EVENT_RUN_END, async () => {
176
193
  try {
194
+ debugOnConsole(`[MOCHA EVENT] EVENT_RUN_END`);
177
195
  if(this.testObservability == true) {
178
196
  const hookSkippedTests = getHookSkippedTests(this.runner.suite);
179
197
  for(const test of hookSkippedTests) {
180
198
  if(!test.testAnalyticsId) test.testAnalyticsId = uuidv4();
199
+ debugOnConsole(`[MOCHA EVENT] EVENT_RUN_END TestRunSkipped for uuid: ${test.testAnalyticsId}`);
181
200
  await this.sendTestRunEvent(test,undefined,false,"TestRunSkipped");
182
201
  }
183
202
  }
@@ -318,6 +337,8 @@ class MyReporter {
318
337
  }
319
338
  };
320
339
 
340
+ debugOnConsole(`${eventType} for uuid: ${testData.uuid}`);
341
+
321
342
  if(eventType.match(/TestRunFinished/) || eventType.match(/TestRunSkipped/)) {
322
343
  testData['meta'].steps = JSON.parse(JSON.stringify(this.currentTestCucumberSteps));
323
344
  this.currentTestCucumberSteps = [];
@@ -377,6 +398,7 @@ class MyReporter {
377
398
  mapTestHooks(test);
378
399
  }
379
400
  } catch(e) {
401
+ debugOnConsole(`Exception in processing hook data for event ${eventType} with error : ${e}`);
380
402
  debug(`Exception in processing hook data for event ${eventType} with error : ${e}`, true, e);
381
403
  }
382
404
 
@@ -473,6 +495,7 @@ class MyReporter {
473
495
  this.hooksStarted = {};
474
496
  }
475
497
  } catch(error) {
498
+ debugOnConsole(`Exception in populating test data for event ${eventType} with error : ${error}`);
476
499
  debug(`Exception in populating test data for event ${eventType} with error : ${error}`, true, error);
477
500
  }
478
501
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.31.5",
3
+ "version": "1.31.6",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {