browserstack-cypress-cli 1.36.7 → 1.36.9
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/bin/commands/runs.js +9 -0
- package/bin/testObservability/crashReporter/index.js +1 -3
- package/bin/testObservability/cypress/index.js +44 -3
- package/bin/testObservability/helper/helper.js +12 -3
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -13
- package/.nyc_output/1480c3f2-b8f1-4f4a-a59a-83e6ca5904dd.json +0 -1
- package/.nyc_output/771e6012-aa7b-4bb8-b680-2fca6a6eafd2.json +0 -1
- package/.nyc_output/b968a0a5-c10d-40a3-945a-14d600e51f48.json +0 -1
- package/.nyc_output/processinfo/1480c3f2-b8f1-4f4a-a59a-83e6ca5904dd.json +0 -1
- package/.nyc_output/processinfo/771e6012-aa7b-4bb8-b680-2fca6a6eafd2.json +0 -1
- package/.nyc_output/processinfo/b968a0a5-c10d-40a3-945a-14d600e51f48.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
package/bin/commands/runs.js
CHANGED
|
@@ -364,6 +364,15 @@ module.exports = function run(args, rawArgs) {
|
|
|
364
364
|
// stop the Local instance
|
|
365
365
|
if (!turboScaleSession) await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
|
|
366
366
|
|
|
367
|
+
// SDK-6211: send the Test Observability build-stop now — polling has resolved, so
|
|
368
|
+
// the build has finished running on BrowserStack. builds_th.finished_at is stamped
|
|
369
|
+
// server-side when the collector receives this stop event, so firing it here (before
|
|
370
|
+
// the 5s safety wait, artifact download and HTML report generation below) keeps the
|
|
371
|
+
// TRA build "Duration" aligned with the test window instead of the full CLI wall-clock.
|
|
372
|
+
// printBuildLink no-ops on non-observability runs and is idempotent (buildStopped
|
|
373
|
+
// guard); the later handleSyncExit stop becomes a no-op that still honors the exit code.
|
|
374
|
+
await printBuildLink(true);
|
|
375
|
+
|
|
367
376
|
// waiting for 5 secs for upload to complete (as a safety measure)
|
|
368
377
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
369
378
|
|
|
@@ -27,9 +27,7 @@ let packages = {};
|
|
|
27
27
|
|
|
28
28
|
exports.requireModule = (module, internal = false) => {
|
|
29
29
|
let local_path = "";
|
|
30
|
-
if(
|
|
31
|
-
local_path = path.join(process.env["browserStackCwd"], 'node_modules', module);
|
|
32
|
-
} else if(internal) {
|
|
30
|
+
if(internal) {
|
|
33
31
|
local_path = path.join(process.cwd(), 'node_modules', 'browserstack-cypress-cli', 'node_modules', module);
|
|
34
32
|
} else {
|
|
35
33
|
local_path = path.join(process.cwd(), 'node_modules', module);
|
|
@@ -6,6 +6,40 @@ const STEP_KEYWORDS = ['given', 'when', 'then', 'and', 'but', '*'];
|
|
|
6
6
|
let eventsQueue = [];
|
|
7
7
|
let testRunStarted = false;
|
|
8
8
|
|
|
9
|
+
/*
|
|
10
|
+
* Command args (command.attributes.args) and cy.log items are captured raw and can hold
|
|
11
|
+
* circular Cypress runtime objects (e.g. a config-like object whose `renderOptions.host`
|
|
12
|
+
* points back to itself). cy.task() JSON-serializes its payload to ship it from the browser
|
|
13
|
+
* to the Node plugin process, so a circular arg makes Cypress throw
|
|
14
|
+
* "Converting circular structure to JSON" and aborts the run. Decycle the payload before
|
|
15
|
+
* handing it to cy.task so o11y instrumentation can never break the customer's tests. [SDK-6016]
|
|
16
|
+
*/
|
|
17
|
+
const getCircularReplacer = () => {
|
|
18
|
+
const seen = new WeakSet();
|
|
19
|
+
return (key, value) => {
|
|
20
|
+
if (typeof value === 'object' && value !== null) {
|
|
21
|
+
if (seen.has(value)) return '[Circular]';
|
|
22
|
+
seen.add(value);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Returns a decycled, JSON-safe plain object, or `null` if the payload still cannot be
|
|
30
|
+
* serialized for a non-circular reason (BigInt, a throwing toJSON, a Proxy trap, etc.).
|
|
31
|
+
* `null` is a "skip this event" sentinel — callers must NOT forward it to cy.task, because
|
|
32
|
+
* the Node o11y handler expects a structured event payload, not an error stub. Skipping keeps
|
|
33
|
+
* graceful degradation total: no crash, and no malformed event reaches the collector.
|
|
34
|
+
*/
|
|
35
|
+
const sanitizeForTask = (data) => {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(JSON.stringify(data, getCircularReplacer()));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
9
43
|
const browserStackLog = (message) => {
|
|
10
44
|
|
|
11
45
|
if (!Cypress.env('BROWSERSTACK_LOGS')) return;
|
|
@@ -208,7 +242,12 @@ Cypress.on('command:enqueued', (attrs) => {
|
|
|
208
242
|
if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
|
|
209
243
|
const message = args.reduce((result, logItem) => {
|
|
210
244
|
if (typeof logItem === 'object') {
|
|
211
|
-
|
|
245
|
+
/* Route through sanitizeForTask so a non-circular serialization failure can never
|
|
246
|
+
* throw out of the command:enqueued handler (same graceful-degradation contract as
|
|
247
|
+
* the flush sites). sanitizeForTask returns a decycled plain object (safe to stringify)
|
|
248
|
+
* or null; on null, contribute nothing for this item rather than crash. */
|
|
249
|
+
const safeLog = sanitizeForTask(logItem);
|
|
250
|
+
return [result, safeLog === null ? '' : JSON.stringify(safeLog)].join(' ');
|
|
212
251
|
}
|
|
213
252
|
return [result, logItem ? logItem.toString() : ''].join(' ');
|
|
214
253
|
}, '');
|
|
@@ -309,7 +348,8 @@ beforeEach(() => {
|
|
|
309
348
|
|
|
310
349
|
if (eventsQueue.length > 0) {
|
|
311
350
|
eventsQueue.forEach(event => {
|
|
312
|
-
|
|
351
|
+
const payload = sanitizeForTask(event.data);
|
|
352
|
+
if (payload !== null) cy.task(event.task, payload, event.options);
|
|
313
353
|
});
|
|
314
354
|
}
|
|
315
355
|
eventsQueue = [];
|
|
@@ -324,7 +364,8 @@ afterEach(function() {
|
|
|
324
364
|
|
|
325
365
|
if (eventsQueue.length > 0) {
|
|
326
366
|
eventsQueue.forEach(event => {
|
|
327
|
-
|
|
367
|
+
const payload = sanitizeForTask(event.data);
|
|
368
|
+
if (payload !== null) cy.task(event.task, payload, event.options);
|
|
328
369
|
});
|
|
329
370
|
}
|
|
330
371
|
|
|
@@ -93,7 +93,16 @@ const supportFileCleanup = () => {
|
|
|
93
93
|
exports.buildStopped = false;
|
|
94
94
|
|
|
95
95
|
exports.printBuildLink = async (shouldStopSession, exitCode = null) => {
|
|
96
|
-
if(!this.isTestObservabilitySession()
|
|
96
|
+
if(!this.isTestObservabilitySession()) return;
|
|
97
|
+
// SDK-6211: the build-stop may be sent early (runs.js fires it at poll-resolution, before the
|
|
98
|
+
// post-test 5s wait + artifact download + report generation, so builds_th.finished_at — which
|
|
99
|
+
// the collector stamps at stop-event receipt — reflects the test window rather than the full CLI
|
|
100
|
+
// wall-clock). A later call here must therefore still honor the exit code instead of returning
|
|
101
|
+
// silently, preserving the original failing-build exit behaviour.
|
|
102
|
+
if(exports.buildStopped) {
|
|
103
|
+
if(exitCode) process.exit(exitCode);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
97
106
|
exports.buildStopped = true;
|
|
98
107
|
try {
|
|
99
108
|
if(shouldStopSession) {
|
|
@@ -928,9 +937,9 @@ exports.runCypressTestsLocally = (bsConfig, args, rawArgs) => {
|
|
|
928
937
|
rawArgs = cleanupTestObservabilityFlags(rawArgs);
|
|
929
938
|
logger.info(`Running npx cypress run ${getReRunSpecs(rawArgs.slice(1)).join(' ')} ${getLocalSessionReporter().join(' ')}`);
|
|
930
939
|
const cypressProcess = spawn(
|
|
931
|
-
'npx',
|
|
940
|
+
/^win/.test(process.platform) ? 'npx.cmd' : 'npx',
|
|
932
941
|
['cypress', 'run', ...getReRunSpecs(rawArgs.slice(1)), ...getLocalSessionReporter()],
|
|
933
|
-
{ stdio: 'inherit', cwd: process.cwd(), env: process.env, shell:
|
|
942
|
+
{ stdio: 'inherit', cwd: process.cwd(), env: process.env, shell: false }
|
|
934
943
|
);
|
|
935
944
|
cypressProcess.on('close', async (code) => {
|
|
936
945
|
logger.info(`Cypress process exited with code ${code}`);
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|