browserstack-cypress-cli 1.23.0 → 1.24.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.
Files changed (40) hide show
  1. package/.github/workflows/Semgrep.yml +48 -0
  2. package/CODEOWNERS +1 -0
  3. package/bin/commands/runs.js +74 -38
  4. package/bin/helpers/constants.js +4 -1
  5. package/bin/helpers/timezone.json +1714 -0
  6. package/bin/helpers/utils.js +55 -3
  7. package/bin/testObservability/crashReporter/index.js +139 -0
  8. package/bin/testObservability/cypress/index.js +158 -0
  9. package/bin/testObservability/helper/constants.js +30 -0
  10. package/bin/testObservability/helper/helper.js +996 -0
  11. package/bin/testObservability/helper/requestQueueHandler.js +88 -0
  12. package/bin/testObservability/plugin/index.js +40 -0
  13. package/bin/testObservability/plugin/ipcClient.js +16 -0
  14. package/bin/testObservability/plugin/ipcServer.js +34 -0
  15. package/bin/testObservability/reporter/index.js +699 -0
  16. package/package.json +8 -2
  17. package/.nyc_output/2807648c-3b13-4cd1-b949-11ce1b846277.json +0 -1
  18. package/.nyc_output/48e04c5a-5723-4547-b9d6-20074786acab.json +0 -1
  19. package/.nyc_output/51e8de95-1005-492b-8e2f-d7c6fc9148e4.json +0 -1
  20. package/.nyc_output/577e3334-ad22-4b05-ac7f-e0038582bb25.json +0 -1
  21. package/.nyc_output/59cc8cf4-849a-4cb5-bc52-0133091e0584.json +0 -1
  22. package/.nyc_output/5fc28c76-8c92-44e9-9bae-ec2e85892509.json +0 -1
  23. package/.nyc_output/5fffbcf8-4572-45c7-948f-38aeb3421a3e.json +0 -1
  24. package/.nyc_output/6b02b68b-ad99-40ff-b34f-218d98a9c773.json +0 -1
  25. package/.nyc_output/6ec27c2e-3529-412c-a82b-d1b8970a52a5.json +0 -1
  26. package/.nyc_output/7540c691-20e7-4eb9-a21e-75f1b22fe6eb.json +0 -1
  27. package/.nyc_output/79dc2aeb-d682-45b3-8430-eea8b886e5ae.json +0 -1
  28. package/.nyc_output/processinfo/2807648c-3b13-4cd1-b949-11ce1b846277.json +0 -1
  29. package/.nyc_output/processinfo/48e04c5a-5723-4547-b9d6-20074786acab.json +0 -1
  30. package/.nyc_output/processinfo/51e8de95-1005-492b-8e2f-d7c6fc9148e4.json +0 -1
  31. package/.nyc_output/processinfo/577e3334-ad22-4b05-ac7f-e0038582bb25.json +0 -1
  32. package/.nyc_output/processinfo/59cc8cf4-849a-4cb5-bc52-0133091e0584.json +0 -1
  33. package/.nyc_output/processinfo/5fc28c76-8c92-44e9-9bae-ec2e85892509.json +0 -1
  34. package/.nyc_output/processinfo/5fffbcf8-4572-45c7-948f-38aeb3421a3e.json +0 -1
  35. package/.nyc_output/processinfo/6b02b68b-ad99-40ff-b34f-218d98a9c773.json +0 -1
  36. package/.nyc_output/processinfo/6ec27c2e-3529-412c-a82b-d1b8970a52a5.json +0 -1
  37. package/.nyc_output/processinfo/7540c691-20e7-4eb9-a21e-75f1b22fe6eb.json +0 -1
  38. package/.nyc_output/processinfo/79dc2aeb-d682-45b3-8430-eea8b886e5ae.json +0 -1
  39. package/.nyc_output/processinfo/index.json +0 -1
  40. package/log/usage.log +0 -15
@@ -0,0 +1,88 @@
1
+ const { BATCH_SIZE, BATCH_INTERVAL, consoleHolder } = require('./constants');
2
+ const { debug, batchAndPostEvents } = require('./helper');
3
+
4
+ class RequestQueueHandler {
5
+ constructor() {
6
+ this.queue = [];
7
+ this.started = false;
8
+ this.eventUrl = 'api/v1/batch';
9
+ this.screenshotEventUrl = 'api/v1/screenshots';
10
+ this.BATCH_EVENT_TYPES = ['LogCreated', 'CBTSessionCreated', 'TestRunFinished', 'TestRunSkipped', 'HookRunFinished', 'TestRunStarted', 'HookRunStarted', 'BuildUpdate'];
11
+ this.pollEventBatchInterval = null;
12
+ }
13
+
14
+ start = () => {
15
+ if(!this.started) {
16
+ this.started = true;
17
+ this.startEventBatchPolling();
18
+ }
19
+ }
20
+
21
+ add = (event) => {
22
+ if(this.BATCH_EVENT_TYPES.includes(event.event_type)) {
23
+ if(event.logs && event.logs[0] && event.logs[0].kind === 'TEST_SCREENSHOT') {
24
+ return {
25
+ shouldProceed: true,
26
+ proceedWithData: [event],
27
+ proceedWithUrl: this.screenshotEventUrl
28
+ }
29
+ }
30
+
31
+ this.queue.push(event);
32
+ let data = null, shouldProceed = this.shouldProceed();
33
+ if(shouldProceed) {
34
+ data = this.queue.slice(0,BATCH_SIZE);
35
+ this.queue.splice(0,BATCH_SIZE);
36
+ this.resetEventBatchPolling();
37
+ }
38
+
39
+ return {
40
+ shouldProceed: shouldProceed,
41
+ proceedWithData: data,
42
+ proceedWithUrl: this.eventUrl
43
+ }
44
+ } else {
45
+ return {
46
+ shouldProceed: true
47
+ }
48
+ }
49
+ }
50
+
51
+ shutdown = async () => {
52
+ this.removeEventBatchPolling('REMOVING');
53
+ while(this.queue.length > 0) {
54
+ const data = this.queue.slice(0,BATCH_SIZE);
55
+ this.queue.splice(0,BATCH_SIZE);
56
+ await batchAndPostEvents(this.eventUrl,'Shutdown-Queue',data);
57
+ }
58
+ }
59
+
60
+ startEventBatchPolling = () => {
61
+ this.pollEventBatchInterval = setInterval(async () => {
62
+ if(this.queue.length > 0) {
63
+ const data = this.queue.slice(0,BATCH_SIZE);
64
+ this.queue.splice(0,BATCH_SIZE);
65
+ await batchAndPostEvents(this.eventUrl,'Interval-Queue',data);
66
+ }
67
+ }, BATCH_INTERVAL);
68
+ }
69
+
70
+ resetEventBatchPolling = () => {
71
+ this.removeEventBatchPolling('RESETTING');
72
+ this.startEventBatchPolling();
73
+ }
74
+
75
+ removeEventBatchPolling = (tag) => {
76
+ if(this.pollEventBatchInterval) {
77
+ clearInterval(this.pollEventBatchInterval);
78
+ this.pollEventBatchInterval = null;
79
+ if(tag === 'REMOVING') this.started = false;
80
+ }
81
+ }
82
+
83
+ shouldProceed = () => {
84
+ return this.queue.length >= BATCH_SIZE;
85
+ }
86
+ }
87
+
88
+ module.exports = RequestQueueHandler;
@@ -0,0 +1,40 @@
1
+ const ipc = require('node-ipc');
2
+ const { connectIPCClient } = require('./ipcClient');
3
+ const { IPC_EVENTS } = require('../helper/constants');
4
+
5
+ const browserstackTestObservabilityPlugin = (on, config, callbacks) => {
6
+ connectIPCClient(config);
7
+
8
+ on('task', {
9
+ test_observability_log(log) {
10
+ ipc.of.browserstackTestObservability.emit(IPC_EVENTS.LOG, log);
11
+ return null;
12
+ },
13
+ test_observability_command(commandObj) {
14
+ ipc.of.browserstackTestObservability.emit(IPC_EVENTS.COMMAND, commandObj);
15
+ return null;
16
+ },
17
+ test_observability_platform_details(platformObj) {
18
+ ipc.of.browserstackTestObservability.emit(IPC_EVENTS.PLATFORM_DETAILS, platformObj);
19
+ return null;
20
+ },
21
+ test_observability_step(log) {
22
+ ipc.of.browserstackTestObservability.emit(IPC_EVENTS.CUCUMBER, log);
23
+ return null;
24
+ }
25
+ });
26
+
27
+ on('after:screenshot', (screenshotInfo) => {
28
+ let logMessage;
29
+ if (callbacks && callbacks.screenshotLogFn && typeof callbacks.screenshotLogFn === 'function') {
30
+ logMessage = callbacks.screenshotLogFn(screenshotInfo);
31
+ }
32
+ ipc.of.browserstackTestObservability.emit(IPC_EVENTS.SCREENSHOT, {
33
+ logMessage,
34
+ screenshotInfo,
35
+ });
36
+ return null;
37
+ });
38
+ };
39
+
40
+ module.exports = browserstackTestObservabilityPlugin;
@@ -0,0 +1,16 @@
1
+ const ipc = require('node-ipc');
2
+ const { IPC_EVENTS } = require('../helper/constants');
3
+
4
+ exports.connectIPCClient = (config) => {
5
+ ipc.config.id = 'browserstackTestObservability';
6
+ ipc.config.retry = 1500;
7
+ ipc.config.silent = true;
8
+
9
+ ipc.connectTo('browserstackTestObservability', () => {
10
+ ipc.of.browserstackTestObservability.on('connect', () => {
11
+ ipc.of.browserstackTestObservability.emit(IPC_EVENTS.CONFIG, config);
12
+ });
13
+ ipc.of.browserstackTestObservability.on('disconnect', () => {
14
+ });
15
+ });
16
+ };
@@ -0,0 +1,34 @@
1
+ const ipc = require('node-ipc');
2
+ const { consoleHolder } = require('../helper/constants');
3
+
4
+ exports.startIPCServer = (subscribeServerEvents, unsubscribeServerEvents) => {
5
+ if (ipc.server) {
6
+ unsubscribeServerEvents(ipc.server);
7
+ subscribeServerEvents(ipc.server);
8
+ return;
9
+ }
10
+ ipc.config.id = 'browserstackTestObservability';
11
+ ipc.config.retry = 1500;
12
+ ipc.config.silent = true;
13
+
14
+ ipc.serve(() => {
15
+
16
+ ipc.server.on('socket.disconnected', (socket, destroyedSocketID) => {
17
+ ipc.log(`client ${destroyedSocketID} has disconnected!`);
18
+ });
19
+
20
+ ipc.server.on('destroy', () => {
21
+ ipc.log('server destroyed');
22
+ });
23
+
24
+ subscribeServerEvents(ipc.server);
25
+
26
+ process.on('exit', () => {
27
+ unsubscribeServerEvents(ipc.server);
28
+ ipc.server.stop();
29
+ });
30
+
31
+ });
32
+
33
+ ipc.server.start();
34
+ };