browserstack-cypress-cli 1.32.8 → 1.34.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.
- package/.claude/settings.local.json +13 -0
- package/.nyc_output/1c1b6051-514d-4847-bd2a-d03b2d537cfb.json +1 -0
- package/.nyc_output/20afa9bb-5b9f-42e2-adfe-9dbf55591bb8.json +1 -0
- package/.nyc_output/22e511c5-8971-4265-b783-553560573bdc.json +1 -0
- package/.nyc_output/2d21e700-0ac9-4ac9-8f8c-322a5cbefe8d.json +1 -0
- package/.nyc_output/3c54171a-9bf6-478d-a4c0-28ec402806cf.json +1 -0
- package/.nyc_output/52675bfd-ff62-4f5b-944c-e3f48af2972c.json +1 -0
- package/.nyc_output/5766c03a-3d68-4298-89f7-c298c025e176.json +1 -0
- package/.nyc_output/625adc06-9859-4c11-8892-0498922cc2aa.json +1 -0
- package/.nyc_output/730f797e-97d0-44a8-b5d0-7fd3f8c06d75.json +1 -0
- package/.nyc_output/73501809-7c04-439e-8c09-9a1bff7962c6.json +1 -0
- package/.nyc_output/77484870-1b25-4c2d-a361-2ac51c0951bc.json +1 -0
- package/.nyc_output/8098fa2d-312d-4762-ad96-3e9827eaef09.json +1 -0
- package/.nyc_output/87357e21-685f-4861-9a6f-4c6b62f85ac0.json +1 -0
- package/.nyc_output/8fcd9f27-af41-43f7-bdf8-7bea2efd7abb.json +1 -0
- package/.nyc_output/9f8ad8fd-775b-4a99-ba77-c6142e7df5e9.json +1 -0
- package/.nyc_output/a1de1cdd-5eed-409d-a528-1c7cf16d56b5.json +1 -0
- package/.nyc_output/a25237ac-032d-4a27-af09-fb32326b539a.json +1 -0
- package/.nyc_output/a5d38a55-372c-4676-b4bc-c6def0669c0d.json +1 -0
- package/.nyc_output/a67d3cbf-0548-4fcb-8aad-2af60b532670.json +1 -0
- package/.nyc_output/aa2117b0-10c0-4f5b-9d8d-1f96375f0240.json +1 -0
- package/.nyc_output/ac17471f-3f16-45ab-b53e-ba8956afd5d4.json +1 -0
- package/.nyc_output/bbbe672a-8524-4850-b6b3-b725aa2b6c16.json +1 -0
- package/.nyc_output/c7289c09-7047-47cb-9737-f11fe7fc9628.json +1 -0
- package/.nyc_output/ceeeac29-3ca3-40af-b779-12c0408cf05d.json +1 -0
- package/.nyc_output/d08d37a4-6abc-41a7-98bd-de074a1fca7f.json +1 -0
- package/.nyc_output/d1dbecb0-8458-41bc-86c8-9d2470b60415.json +1 -0
- package/.nyc_output/d7245fa2-3732-4790-831b-44dbcba15a16.json +1 -0
- package/.nyc_output/e184572f-281b-4bd6-81e3-58842eac98ee.json +1 -0
- package/.nyc_output/efd98bd9-1699-472b-ab98-0808e5d39899.json +1 -0
- package/.nyc_output/processinfo/1c1b6051-514d-4847-bd2a-d03b2d537cfb.json +1 -0
- package/.nyc_output/processinfo/20afa9bb-5b9f-42e2-adfe-9dbf55591bb8.json +1 -0
- package/.nyc_output/processinfo/22e511c5-8971-4265-b783-553560573bdc.json +1 -0
- package/.nyc_output/processinfo/2d21e700-0ac9-4ac9-8f8c-322a5cbefe8d.json +1 -0
- package/.nyc_output/processinfo/3c54171a-9bf6-478d-a4c0-28ec402806cf.json +1 -0
- package/.nyc_output/processinfo/52675bfd-ff62-4f5b-944c-e3f48af2972c.json +1 -0
- package/.nyc_output/processinfo/5766c03a-3d68-4298-89f7-c298c025e176.json +1 -0
- package/.nyc_output/processinfo/625adc06-9859-4c11-8892-0498922cc2aa.json +1 -0
- package/.nyc_output/processinfo/730f797e-97d0-44a8-b5d0-7fd3f8c06d75.json +1 -0
- package/.nyc_output/processinfo/73501809-7c04-439e-8c09-9a1bff7962c6.json +1 -0
- package/.nyc_output/processinfo/77484870-1b25-4c2d-a361-2ac51c0951bc.json +1 -0
- package/.nyc_output/processinfo/8098fa2d-312d-4762-ad96-3e9827eaef09.json +1 -0
- package/.nyc_output/processinfo/87357e21-685f-4861-9a6f-4c6b62f85ac0.json +1 -0
- package/.nyc_output/processinfo/8fcd9f27-af41-43f7-bdf8-7bea2efd7abb.json +1 -0
- package/.nyc_output/processinfo/9f8ad8fd-775b-4a99-ba77-c6142e7df5e9.json +1 -0
- package/.nyc_output/processinfo/a1de1cdd-5eed-409d-a528-1c7cf16d56b5.json +1 -0
- package/.nyc_output/processinfo/a25237ac-032d-4a27-af09-fb32326b539a.json +1 -0
- package/.nyc_output/processinfo/a5d38a55-372c-4676-b4bc-c6def0669c0d.json +1 -0
- package/.nyc_output/processinfo/a67d3cbf-0548-4fcb-8aad-2af60b532670.json +1 -0
- package/.nyc_output/processinfo/aa2117b0-10c0-4f5b-9d8d-1f96375f0240.json +1 -0
- package/.nyc_output/processinfo/ac17471f-3f16-45ab-b53e-ba8956afd5d4.json +1 -0
- package/.nyc_output/processinfo/bbbe672a-8524-4850-b6b3-b725aa2b6c16.json +1 -0
- package/.nyc_output/processinfo/c7289c09-7047-47cb-9737-f11fe7fc9628.json +1 -0
- package/.nyc_output/processinfo/ceeeac29-3ca3-40af-b779-12c0408cf05d.json +1 -0
- package/.nyc_output/processinfo/d08d37a4-6abc-41a7-98bd-de074a1fca7f.json +1 -0
- package/.nyc_output/processinfo/d1dbecb0-8458-41bc-86c8-9d2470b60415.json +1 -0
- package/.nyc_output/processinfo/d7245fa2-3732-4790-831b-44dbcba15a16.json +1 -0
- package/.nyc_output/processinfo/e184572f-281b-4bd6-81e3-58842eac98ee.json +1 -0
- package/.nyc_output/processinfo/efd98bd9-1699-472b-ab98-0808e5d39899.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/bin/accessibility-automation/cypress/index.js +1 -1
- package/bin/accessibility-automation/helper.js +60 -32
- package/bin/commands/runs.js +10 -3
- package/bin/helpers/build.js +2 -0
- package/bin/helpers/capabilityHelper.js +7 -1
- package/bin/helpers/constants.js +22 -0
- package/bin/helpers/helper.js +2 -1
- package/bin/helpers/packageInstaller.js +3 -2
- package/bin/helpers/readCypressConfigUtil.js +133 -11
- package/bin/helpers/utils.js +241 -3
- package/bin/templates/configTemplate.js +2 -0
- package/bin/testObservability/crashReporter/index.js +2 -2
- package/bin/testObservability/cypress/index.js +194 -96
- package/bin/testObservability/helper/cleanupQueueSync.js +1 -2
- package/bin/testObservability/helper/constants.js +4 -0
- package/bin/testObservability/helper/helper.js +21 -22
- package/bin/testObservability/helper/requestQueueHandler.js +1 -1
- package/bin/testObservability/plugin/index.js +6 -0
- package/bin/testObservability/plugin/ipcServer.js +1 -1
- package/bin/testObservability/reporter/index.js +26 -18
- package/log/usage.log +393 -4
- package/package.json +6 -5
|
@@ -1,86 +1,137 @@
|
|
|
1
1
|
/* Event listeners + custom commands for Cypress */
|
|
2
2
|
|
|
3
3
|
/* Used to detect Gherkin steps */
|
|
4
|
+
|
|
5
|
+
const util = require('util');
|
|
6
|
+
|
|
7
|
+
let eventsQueue = [];
|
|
8
|
+
let testRunStarted = false;
|
|
9
|
+
|
|
10
|
+
const browserStackLog = (message) => {
|
|
11
|
+
|
|
12
|
+
if (!Cypress.env('BROWSERSTACK_LOGS')) return;
|
|
13
|
+
cy.task('browserstack_log', message);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const shouldSkipCommand = (command) => {
|
|
17
|
+
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command', 'browserstack_log', 'test_observability_log'].some(event => command.attributes.args.includes(event))));
|
|
21
|
+
}
|
|
22
|
+
|
|
4
23
|
Cypress.on('log:added', (log) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, {log: false})
|
|
24
|
+
return () => {
|
|
25
|
+
if (shouldSkipCommand(command)) {
|
|
26
|
+
return;
|
|
9
27
|
}
|
|
10
|
-
|
|
11
|
-
|
|
28
|
+
eventsQueue.push({
|
|
29
|
+
task: 'test_observability_step',
|
|
30
|
+
data: {
|
|
31
|
+
log,
|
|
32
|
+
started_at: new Date().toISOString(),
|
|
33
|
+
finished_at: new Date().toISOString()
|
|
34
|
+
},
|
|
35
|
+
options: { log: false }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
12
40
|
Cypress.on('command:start', (command) => {
|
|
13
|
-
|
|
14
|
-
if
|
|
41
|
+
|
|
42
|
+
if (!command || !command.attributes) return;
|
|
43
|
+
if (shouldSkipCommand(command)) {
|
|
15
44
|
return;
|
|
16
45
|
}
|
|
46
|
+
|
|
17
47
|
/* Send command details */
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
48
|
+
eventsQueue.push({
|
|
49
|
+
task: 'test_observability_command',
|
|
50
|
+
data: {
|
|
51
|
+
type: 'COMMAND_START',
|
|
52
|
+
command: {
|
|
53
|
+
attributes: {
|
|
54
|
+
id: command.attributes.id,
|
|
55
|
+
name: command.attributes.name,
|
|
56
|
+
args: command.attributes.args
|
|
57
|
+
},
|
|
58
|
+
state: 'pending',
|
|
59
|
+
started_at: new Date().toISOString(),
|
|
60
|
+
location: testRunStarted ? 'test' : 'hook'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
options: { log: false }
|
|
30
64
|
});
|
|
31
|
-
|
|
32
65
|
/* Send platform details */
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
66
|
+
let testTitle = '';
|
|
67
|
+
try {
|
|
68
|
+
const runner = Cypress.mocha.getRunner();
|
|
69
|
+
const ctx = runner.suite.ctx;
|
|
70
|
+
testTitle = ctx.currentTest.title || ctx._runnable.title;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
// Silently handle if any property is undefined
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
eventsQueue.push({
|
|
76
|
+
task: 'test_observability_platform_details',
|
|
77
|
+
data: {
|
|
78
|
+
testTitle,
|
|
79
|
+
browser: Cypress.browser,
|
|
80
|
+
platform: Cypress.platform,
|
|
81
|
+
cypressVersion: Cypress.version
|
|
82
|
+
},
|
|
83
|
+
options: { log: false }
|
|
40
84
|
});
|
|
41
85
|
});
|
|
42
86
|
|
|
43
87
|
Cypress.on('command:retry', (command) => {
|
|
44
|
-
if(!command || !command.attributes) return;
|
|
45
|
-
if
|
|
88
|
+
if (!command || !command.attributes) return;
|
|
89
|
+
if (shouldSkipCommand(command)) {
|
|
46
90
|
return;
|
|
47
91
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
92
|
+
eventsQueue.push({
|
|
93
|
+
task: 'test_observability_command',
|
|
94
|
+
data: {
|
|
95
|
+
type: 'COMMAND_RETRY',
|
|
96
|
+
command: {
|
|
97
|
+
_log: command._log,
|
|
98
|
+
error: {
|
|
99
|
+
message: command && command.error ? command.error.message : null,
|
|
100
|
+
isDefaultAssertionErr: command && command.error ? command.error.isDefaultAssertionErr : null
|
|
101
|
+
},
|
|
102
|
+
location: testRunStarted ? 'test' : 'hook'
|
|
55
103
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}).catch((err) => {
|
|
104
|
+
},
|
|
105
|
+
options: { log: false }
|
|
59
106
|
});
|
|
60
107
|
});
|
|
61
108
|
|
|
62
109
|
Cypress.on('command:end', (command) => {
|
|
63
|
-
if(!command || !command.attributes) return;
|
|
64
|
-
if
|
|
110
|
+
if (!command || !command.attributes) return;
|
|
111
|
+
if (shouldSkipCommand(command)) {
|
|
65
112
|
return;
|
|
66
113
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
'
|
|
71
|
-
|
|
72
|
-
'
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
114
|
+
eventsQueue.push({
|
|
115
|
+
task: 'test_observability_command',
|
|
116
|
+
data: {
|
|
117
|
+
'type': 'COMMAND_END',
|
|
118
|
+
'command': {
|
|
119
|
+
'attributes': {
|
|
120
|
+
'id': command.attributes.id,
|
|
121
|
+
'name': command.attributes.name,
|
|
122
|
+
'args': command.attributes.args
|
|
123
|
+
},
|
|
124
|
+
'state': command.state,
|
|
125
|
+
finished_at: new Date().toISOString(),
|
|
126
|
+
location: testRunStarted ? 'test' : 'hook'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
options: { log: false }
|
|
79
130
|
});
|
|
80
131
|
});
|
|
81
132
|
|
|
82
133
|
Cypress.Commands.overwrite('log', (originalFn, ...args) => {
|
|
83
|
-
if(args.includes('test_observability_log') || args.includes('test_observability_command')) return;
|
|
134
|
+
if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
|
|
84
135
|
const message = args.reduce((result, logItem) => {
|
|
85
136
|
if (typeof logItem === 'object') {
|
|
86
137
|
return [result, JSON.stringify(logItem)].join(' ');
|
|
@@ -88,71 +139,118 @@ Cypress.Commands.overwrite('log', (originalFn, ...args) => {
|
|
|
88
139
|
|
|
89
140
|
return [result, logItem ? logItem.toString() : ''].join(' ');
|
|
90
141
|
}, '');
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
142
|
+
eventsQueue.push({
|
|
143
|
+
task: 'test_observability_log',
|
|
144
|
+
data: {
|
|
145
|
+
'level': 'info',
|
|
146
|
+
message,
|
|
147
|
+
timestamp: new Date().toISOString()
|
|
148
|
+
},
|
|
149
|
+
options: { log: false }
|
|
96
150
|
});
|
|
97
151
|
originalFn(...args);
|
|
98
152
|
});
|
|
99
153
|
|
|
100
154
|
Cypress.Commands.add('trace', (message, file) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
155
|
+
eventsQueue.push({
|
|
156
|
+
task: 'test_observability_log',
|
|
157
|
+
data: {
|
|
158
|
+
level: 'trace',
|
|
159
|
+
message,
|
|
160
|
+
file,
|
|
161
|
+
},
|
|
162
|
+
options: { log: false }
|
|
107
163
|
});
|
|
108
164
|
});
|
|
109
165
|
|
|
110
166
|
Cypress.Commands.add('logDebug', (message, file) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
167
|
+
eventsQueue.push({
|
|
168
|
+
task: 'test_observability_log',
|
|
169
|
+
data: {
|
|
170
|
+
level: 'debug',
|
|
171
|
+
message,
|
|
172
|
+
file,
|
|
173
|
+
},
|
|
174
|
+
options: { log: false }
|
|
117
175
|
});
|
|
118
176
|
});
|
|
119
177
|
|
|
120
178
|
Cypress.Commands.add('info', (message, file) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
179
|
+
eventsQueue.push({
|
|
180
|
+
task: 'test_observability_log',
|
|
181
|
+
data: {
|
|
182
|
+
level: 'info',
|
|
183
|
+
message,
|
|
184
|
+
file,
|
|
185
|
+
},
|
|
186
|
+
options: { log: false }
|
|
127
187
|
});
|
|
128
188
|
});
|
|
129
189
|
|
|
130
190
|
Cypress.Commands.add('warn', (message, file) => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
191
|
+
eventsQueue.push({
|
|
192
|
+
task: 'test_observability_log',
|
|
193
|
+
data: {
|
|
194
|
+
level: 'warn',
|
|
195
|
+
message,
|
|
196
|
+
file,
|
|
197
|
+
},
|
|
198
|
+
options: { log: false }
|
|
137
199
|
});
|
|
138
200
|
});
|
|
139
201
|
|
|
140
202
|
Cypress.Commands.add('error', (message, file) => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
203
|
+
eventsQueue.push({
|
|
204
|
+
task: 'test_observability_log',
|
|
205
|
+
data: {
|
|
206
|
+
level: 'error',
|
|
207
|
+
message,
|
|
208
|
+
file,
|
|
209
|
+
},
|
|
210
|
+
options: { log: false }
|
|
147
211
|
});
|
|
148
212
|
});
|
|
149
213
|
|
|
150
214
|
Cypress.Commands.add('fatal', (message, file) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
215
|
+
eventsQueue.push({
|
|
216
|
+
task: 'test_observability_log',
|
|
217
|
+
data: {
|
|
218
|
+
level: 'fatal',
|
|
219
|
+
message,
|
|
220
|
+
file,
|
|
221
|
+
},
|
|
222
|
+
options: { log: false }
|
|
157
223
|
});
|
|
158
224
|
});
|
|
225
|
+
|
|
226
|
+
beforeEach(() => {
|
|
227
|
+
/* browserstack internal helper hook */
|
|
228
|
+
|
|
229
|
+
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (eventsQueue.length > 0) {
|
|
234
|
+
eventsQueue.forEach(event => {
|
|
235
|
+
cy.task(event.task, event.data, event.options);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
eventsQueue = [];
|
|
239
|
+
testRunStarted = true;
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
afterEach(function() {
|
|
243
|
+
/* browserstack internal helper hook */
|
|
244
|
+
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (eventsQueue.length > 0) {
|
|
249
|
+
eventsQueue.forEach(event => {
|
|
250
|
+
cy.task(event.task, event.data, event.options);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
eventsQueue = [];
|
|
255
|
+
testRunStarted = false;
|
|
256
|
+
});
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Sending all the remaining queues for synchronous manner
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const requestHandler = require('./requestQueueHandler');
|
|
6
6
|
|
|
7
7
|
const shutdown = async () => {
|
|
8
|
-
const requestHandler = new RequestQueueHandler();
|
|
9
8
|
requestHandler.queue = require(process.argv[2].trim());
|
|
10
9
|
await requestHandler.shutdown();
|
|
11
10
|
}
|
|
@@ -16,6 +16,7 @@ exports.IPC_EVENTS = {
|
|
|
16
16
|
|
|
17
17
|
exports.OBSERVABILITY_ENV_VARS = [
|
|
18
18
|
"BROWSERSTACK_TEST_OBSERVABILITY",
|
|
19
|
+
"BROWSERSTACK_TEST_REPORTING",
|
|
19
20
|
"BROWSERSTACK_AUTOMATION",
|
|
20
21
|
"BS_TESTOPS_BUILD_COMPLETED",
|
|
21
22
|
"BS_TESTOPS_JWT",
|
|
@@ -23,6 +24,7 @@ exports.OBSERVABILITY_ENV_VARS = [
|
|
|
23
24
|
"BS_TESTOPS_ALLOW_SCREENSHOTS",
|
|
24
25
|
"OBSERVABILITY_LAUNCH_SDK_VERSION",
|
|
25
26
|
"BROWSERSTACK_OBSERVABILITY_DEBUG",
|
|
27
|
+
"BROWSERSTACK_TEST_REPORTING_DEBUG",
|
|
26
28
|
"OBS_CRASH_REPORTING_USERNAME",
|
|
27
29
|
"OBS_CRASH_REPORTING_ACCESS_KEY",
|
|
28
30
|
"OBS_CRASH_REPORTING_BS_CONFIG_PATH",
|
|
@@ -34,3 +36,5 @@ exports.TEST_OBSERVABILITY_REPORTER = 'browserstack-cypress-cli/bin/testObservab
|
|
|
34
36
|
exports.TEST_OBSERVABILITY_REPORTER_LOCAL = path.join(__dirname, '..', 'reporter');
|
|
35
37
|
|
|
36
38
|
exports.PENDING_QUEUES_FILE = `pending_queues_${process.pid}.json`;
|
|
39
|
+
|
|
40
|
+
exports.TEST_REPORTING_ANALYTICS = 'TEST REPORTING AND ANALYTICS';
|
|
@@ -27,7 +27,7 @@ const GLOBAL_MODULE_PATH = execSync('npm root -g').toString().trim();
|
|
|
27
27
|
const { name, version } = require('../../../package.json');
|
|
28
28
|
|
|
29
29
|
const { CYPRESS_V10_AND_ABOVE_CONFIG_FILE_EXTENSIONS } = require('../../helpers/constants');
|
|
30
|
-
const { consoleHolder, API_URL, TEST_OBSERVABILITY_REPORTER, TEST_OBSERVABILITY_REPORTER_LOCAL } = require('./constants');
|
|
30
|
+
const { consoleHolder, API_URL, TEST_OBSERVABILITY_REPORTER, TEST_OBSERVABILITY_REPORTER_LOCAL, TEST_REPORTING_ANALYTICS } = require('./constants');
|
|
31
31
|
|
|
32
32
|
const ALLOWED_MODULES = [
|
|
33
33
|
'cypress/package.json',
|
|
@@ -43,13 +43,13 @@ exports.pending_test_uploads = {
|
|
|
43
43
|
exports.debugOnConsole = (text) => {
|
|
44
44
|
if ((process.env.BROWSERSTACK_OBSERVABILITY_DEBUG + '') === "true" ||
|
|
45
45
|
(process.env.BROWSERSTACK_OBSERVABILITY_DEBUG + '') === "1") {
|
|
46
|
-
consoleHolder.log(`[
|
|
46
|
+
consoleHolder.log(`[ ${TEST_REPORTING_ANALYTICS} ] ${text}`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
exports.debug = (text, shouldReport = false, throwable = null) => {
|
|
51
51
|
if (process.env.BROWSERSTACK_OBSERVABILITY_DEBUG === "true" || process.env.BROWSERSTACK_OBSERVABILITY_DEBUG === "1") {
|
|
52
|
-
logger.info(`[
|
|
52
|
+
logger.info(`[ ${TEST_REPORTING_ANALYTICS} ] ${text}`);
|
|
53
53
|
}
|
|
54
54
|
if(shouldReport) {
|
|
55
55
|
CrashReporter.getInstance().uploadCrashReport(text, throwable ? throwable && throwable.stack : null);
|
|
@@ -105,7 +105,7 @@ exports.printBuildLink = async (shouldStopSession, exitCode = null) => {
|
|
|
105
105
|
&& process.env.BS_TESTOPS_BUILD_HASHED_ID != "null"
|
|
106
106
|
&& process.env.BS_TESTOPS_BUILD_HASHED_ID != "undefined") {
|
|
107
107
|
console.log();
|
|
108
|
-
logger.info(`Visit https://
|
|
108
|
+
logger.info(`Visit https://automation.browserstack.com/builds/${process.env.BS_TESTOPS_BUILD_HASHED_ID} to view build report, insights, and many more debugging information all at one place!\n`);
|
|
109
109
|
}
|
|
110
110
|
} catch(err) {
|
|
111
111
|
exports.debug('Build Not Found');
|
|
@@ -117,6 +117,7 @@ exports.printBuildLink = async (shouldStopSession, exitCode = null) => {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
const nodeRequest = (type, url, data, config) => {
|
|
120
|
+
const requestQueueHandler = require('./requestQueueHandler');
|
|
120
121
|
return new Promise(async (resolve, reject) => {
|
|
121
122
|
const options = {
|
|
122
123
|
...config,
|
|
@@ -140,8 +141,8 @@ const nodeRequest = (type, url, data, config) => {
|
|
|
140
141
|
options.proxy = false
|
|
141
142
|
options.httpsAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
-
if(url ===
|
|
144
|
+
|
|
145
|
+
if(url === requestQueueHandler.screenshotEventUrl) {
|
|
145
146
|
options.agent = httpsScreenshotsKeepAliveAgent;
|
|
146
147
|
}
|
|
147
148
|
axios(options)
|
|
@@ -417,7 +418,7 @@ exports.launchTestSession = async (user_config, bsConfigPath) => {
|
|
|
417
418
|
exports.debug('Build creation successfull!');
|
|
418
419
|
process.env.BS_TESTOPS_BUILD_COMPLETED = true;
|
|
419
420
|
setEnvironmentVariablesForRemoteReporter(response.data.jwt, response.data.build_hashed_id, response.data.allow_screenshots, data.observability_version.sdkVersion);
|
|
420
|
-
if(this.isBrowserstackInfra()) helper.setBrowserstackCypressCliDependency(user_config);
|
|
421
|
+
if(this.isBrowserstackInfra() && (user_config.run_settings.auto_import_dev_dependencies != true)) helper.setBrowserstackCypressCliDependency(user_config);
|
|
421
422
|
} catch(error) {
|
|
422
423
|
if(!error.errorType) {
|
|
423
424
|
if (error.response) {
|
|
@@ -513,18 +514,16 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => {
|
|
|
513
514
|
} catch(error) {
|
|
514
515
|
exports.debugOnConsole(`[Request Error] Error in sending request ${util.format(error)}`);
|
|
515
516
|
if (error.response) {
|
|
516
|
-
exports.debug(`EXCEPTION IN ${kind} REQUEST TO
|
|
517
|
+
exports.debug(`EXCEPTION IN ${kind} REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error);
|
|
517
518
|
} else {
|
|
518
|
-
exports.debug(`EXCEPTION IN ${kind} REQUEST TO
|
|
519
|
+
exports.debug(`EXCEPTION IN ${kind} REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.message || error}`, true, error);
|
|
519
520
|
}
|
|
520
521
|
exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count - data.length);
|
|
521
522
|
}
|
|
522
523
|
}
|
|
523
524
|
|
|
524
|
-
const RequestQueueHandler = require('./requestQueueHandler');
|
|
525
|
-
exports.requestQueueHandler = new RequestQueueHandler();
|
|
526
|
-
|
|
527
525
|
exports.uploadEventData = async (eventData, run=0) => {
|
|
526
|
+
const requestQueueHandler = require('./requestQueueHandler');
|
|
528
527
|
exports.debugOnConsole(`[uploadEventData] ${eventData.event_type}`);
|
|
529
528
|
const log_tag = {
|
|
530
529
|
['TestRunStarted']: 'Test_Start_Upload',
|
|
@@ -541,7 +540,7 @@ exports.uploadEventData = async (eventData, run=0) => {
|
|
|
541
540
|
|
|
542
541
|
if (process.env.BS_TESTOPS_BUILD_COMPLETED === "true") {
|
|
543
542
|
if(process.env.BS_TESTOPS_JWT == "null") {
|
|
544
|
-
exports.debug(`EXCEPTION IN ${log_tag} REQUEST TO
|
|
543
|
+
exports.debug(`EXCEPTION IN ${log_tag} REQUEST TO ${TEST_REPORTING_ANALYTICS}: missing authentication token`);
|
|
545
544
|
exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count-1);
|
|
546
545
|
return {
|
|
547
546
|
status: 'error',
|
|
@@ -550,8 +549,8 @@ exports.uploadEventData = async (eventData, run=0) => {
|
|
|
550
549
|
} else {
|
|
551
550
|
let data = eventData, event_api_url = 'api/v1/event';
|
|
552
551
|
|
|
553
|
-
|
|
554
|
-
const { shouldProceed, proceedWithData, proceedWithUrl } =
|
|
552
|
+
requestQueueHandler.start();
|
|
553
|
+
const { shouldProceed, proceedWithData, proceedWithUrl } = requestQueueHandler.add(eventData);
|
|
555
554
|
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`)
|
|
556
555
|
if(!shouldProceed) {
|
|
557
556
|
return;
|
|
@@ -576,7 +575,7 @@ exports.uploadEventData = async (eventData, run=0) => {
|
|
|
576
575
|
if(response.data.error) {
|
|
577
576
|
throw({message: response.data.error});
|
|
578
577
|
} else {
|
|
579
|
-
exports.debug(`${event_api_url !==
|
|
578
|
+
exports.debug(`${event_api_url !== requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'}[${run}] event successfull!`)
|
|
580
579
|
exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count - (event_api_url === 'api/v1/event' ? 1 : data.length));
|
|
581
580
|
return {
|
|
582
581
|
status: 'success',
|
|
@@ -586,9 +585,9 @@ exports.uploadEventData = async (eventData, run=0) => {
|
|
|
586
585
|
} catch(error) {
|
|
587
586
|
exports.debugOnConsole(`[Request Error] Error in sending request ${util.format(error)}`);
|
|
588
587
|
if (error.response) {
|
|
589
|
-
exports.debug(`EXCEPTION IN ${event_api_url !==
|
|
588
|
+
exports.debug(`EXCEPTION IN ${event_api_url !== requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error);
|
|
590
589
|
} else {
|
|
591
|
-
exports.debug(`EXCEPTION IN ${event_api_url !==
|
|
590
|
+
exports.debug(`EXCEPTION IN ${event_api_url !== requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.message || error}`, true, error);
|
|
592
591
|
}
|
|
593
592
|
exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count - (event_api_url === 'api/v1/event' ? 1 : data.length));
|
|
594
593
|
return {
|
|
@@ -598,7 +597,7 @@ exports.uploadEventData = async (eventData, run=0) => {
|
|
|
598
597
|
}
|
|
599
598
|
}
|
|
600
599
|
} else if (run >= 5) {
|
|
601
|
-
exports.debug(`EXCEPTION IN ${log_tag} REQUEST TO
|
|
600
|
+
exports.debug(`EXCEPTION IN ${log_tag} REQUEST TO ${TEST_REPORTING_ANALYTICS} : Build Start is not completed and ${log_tag} retry runs exceeded`);
|
|
602
601
|
if(process.env.BS_TESTOPS_JWT != "null") exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count-1);
|
|
603
602
|
return {
|
|
604
603
|
status: 'error',
|
|
@@ -664,7 +663,7 @@ exports.shouldReRunObservabilityTests = () => {
|
|
|
664
663
|
exports.stopBuildUpstream = async () => {
|
|
665
664
|
if (process.env.BS_TESTOPS_BUILD_COMPLETED === "true") {
|
|
666
665
|
if(process.env.BS_TESTOPS_JWT == "null" || process.env.BS_TESTOPS_BUILD_HASHED_ID == "null") {
|
|
667
|
-
exports.debug(
|
|
666
|
+
exports.debug(`EXCEPTION IN stopBuildUpstream REQUEST TO ${TEST_REPORTING_ANALYTICS} : Missing authentication token`);
|
|
668
667
|
return {
|
|
669
668
|
status: 'error',
|
|
670
669
|
message: 'Token/buildID is undefined, build creation might have failed'
|
|
@@ -694,9 +693,9 @@ exports.stopBuildUpstream = async () => {
|
|
|
694
693
|
}
|
|
695
694
|
} catch(error) {
|
|
696
695
|
if (error.response) {
|
|
697
|
-
exports.debug(`EXCEPTION IN stopBuildUpstream REQUEST TO
|
|
696
|
+
exports.debug(`EXCEPTION IN stopBuildUpstream REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error);
|
|
698
697
|
} else {
|
|
699
|
-
exports.debug(`EXCEPTION IN stopBuildUpstream REQUEST TO
|
|
698
|
+
exports.debug(`EXCEPTION IN stopBuildUpstream REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.message || error}`, true, error);
|
|
700
699
|
}
|
|
701
700
|
return {
|
|
702
701
|
status: 'error',
|
|
@@ -3,6 +3,12 @@ const { connectIPCClient } = require('./ipcClient');
|
|
|
3
3
|
const { IPC_EVENTS } = require('../helper/constants');
|
|
4
4
|
|
|
5
5
|
const browserstackTestObservabilityPlugin = (on, config, callbacks) => {
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
config.env.BROWSERSTACK_O11Y_LOGS = 'true';
|
|
9
|
+
process.env.BROWSERSTACK_O11Y_LOGS = 'true';
|
|
10
|
+
} catch (err) {}
|
|
11
|
+
|
|
6
12
|
connectIPCClient(config);
|
|
7
13
|
|
|
8
14
|
on('task', {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const ipc = require('node-ipc');
|
|
2
2
|
const { consoleHolder } = require('../helper/constants');
|
|
3
|
-
const
|
|
3
|
+
const requestQueueHandler = require('../helper/requestQueueHandler');
|
|
4
4
|
|
|
5
5
|
exports.startIPCServer = (subscribeServerEvents, unsubscribeServerEvents) => {
|
|
6
6
|
if (ipc.server) {
|