Skip to content

Commit 922daf8

Browse files
authored
Merge pull request #1225 from browserstack/APS-22894-cypress-16-expose
2 parents aedf9e9 + e64dcc1 commit 922daf8

11 files changed

Lines changed: 447 additions & 34 deletions

File tree

‎bin/accessibility-automation/cypress/index.js‎

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
/* Event listeners + custom commands for Cypress */
22

3+
/*
4+
* Cypress 16 removed Cypress.env() from the browser; values set by the Node plugin now reach
5+
* the browser through config.expose / Cypress.expose() (available from Cypress 15.10). The
6+
* plugin writes every value to both config.env and config.expose, so read expose first and
7+
* fall back to Cypress.env() for Cypress <= 15.x, where expose does not exist yet. [APS-22894]
8+
*/
9+
const bstackBrowserValue = (key) => {
10+
try {
11+
if (typeof Cypress.expose === 'function') {
12+
const exposed = Cypress.expose(key);
13+
if (exposed !== undefined && exposed !== null) return exposed;
14+
}
15+
} catch (e) {}
16+
try {
17+
return Cypress.env(key);
18+
} catch (e) {
19+
return undefined;
20+
}
21+
};
22+
323
const browserStackLog = (message) => {
4-
if (!Cypress.env('BROWSERSTACK_LOGS')) return;
24+
if (!bstackBrowserValue('BROWSERSTACK_LOGS')) return;
525
cy.task('browserstack_log', message);
626
}
727

@@ -13,7 +33,7 @@ const browserStackLog = (message) => {
1333
let consecutiveA11yTimeouts = 0;
1434
let a11yCircuitOpen = false;
1535
let a11yCircuitLogged = false;
16-
const getA11yCircuitLimit = () => parseInt(Cypress.env('ACCESSIBILITY_SCAN_CIRCUIT_LIMIT')) || 3;
36+
const getA11yCircuitLimit = () => parseInt(bstackBrowserValue('ACCESSIBILITY_SCAN_CIRCUIT_LIMIT')) || 3;
1737
const noteA11yTimeout = () => {
1838
consecutiveA11yTimeouts += 1;
1939
if (!a11yCircuitOpen && consecutiveA11yTimeouts >= getA11yCircuitLimit()) {
@@ -76,7 +96,7 @@ new Promise((resolve) => {
7696
}
7797
let settled = false;
7898
const finish = (val) => { if (!settled) { settled = true; clearTimeout(overallTimer); resolve(val); } };
79-
const overallTimeout = parseInt(Cypress.env('ACCESSIBILITY_SCAN_TIMEOUT')) || 25000;
99+
const overallTimeout = parseInt(bstackBrowserValue('ACCESSIBILITY_SCAN_TIMEOUT')) || 25000;
80100
const overallTimer = setTimeout(() => { noteA11yTimeout(); finish("Accessibility scan timed out"); }, overallTimeout);
81101

82102
try {
@@ -252,7 +272,7 @@ new Promise((resolve) => {
252272
}
253273
let settled = false;
254274
const finish = (val) => { if (!settled) { settled = true; clearTimeout(overallTimer); resolve(val); } };
255-
const overallTimeout = parseInt(Cypress.env('ACCESSIBILITY_SCAN_TIMEOUT')) || 25000;
275+
const overallTimeout = parseInt(bstackBrowserValue('ACCESSIBILITY_SCAN_TIMEOUT')) || 25000;
256276
const overallTimer = setTimeout(() => { noteA11yTimeout(); finish("Accessibility results save timed out"); }, overallTimeout);
257277
try {
258278
const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
@@ -314,24 +334,24 @@ new Promise((resolve) => {
314334
})
315335

316336
const shouldScanForAccessibility = (attributes) => {
317-
if (Cypress.env("IS_ACCESSIBILITY_EXTENSION_LOADED") !== "true") return false;
337+
if (bstackBrowserValue("IS_ACCESSIBILITY_EXTENSION_LOADED") !== "true") return false;
318338

319-
const extensionPath = Cypress.env("ACCESSIBILITY_EXTENSION_PATH");
339+
const extensionPath = bstackBrowserValue("ACCESSIBILITY_EXTENSION_PATH");
320340
const isHeaded = Cypress.browser.isHeaded;
321341

322342
if (!isHeaded || (extensionPath === undefined)) return false;
323343

324344
let shouldScanTestForAccessibility = true;
325345

326-
if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY") || Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
346+
if (bstackBrowserValue("INCLUDE_TAGS_FOR_ACCESSIBILITY") || bstackBrowserValue("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
327347
try {
328348
let includeTagArray = [];
329349
let excludeTagArray = [];
330-
if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY")) {
331-
includeTagArray = Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
350+
if (bstackBrowserValue("INCLUDE_TAGS_FOR_ACCESSIBILITY")) {
351+
includeTagArray = bstackBrowserValue("INCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
332352
}
333-
if (Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
334-
excludeTagArray = Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
353+
if (bstackBrowserValue("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
354+
excludeTagArray = bstackBrowserValue("EXCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
335355
}
336356

337357
const fullTestName = attributes.title;
@@ -383,8 +403,8 @@ afterEach(() => {
383403
cy.wrap(performScan(win), {timeout: 30000}).then(() => {
384404
try {
385405
let os_data;
386-
if (Cypress.env("OS")) {
387-
os_data = Cypress.env("OS");
406+
if (bstackBrowserValue("OS")) {
407+
os_data = bstackBrowserValue("OS");
388408
} else {
389409
os_data = Cypress.platform === 'linux' ? 'mac' : "win"
390410
}
@@ -404,8 +424,8 @@ afterEach(() => {
404424

405425
const payloadToSend = {
406426
"thTestRunUuid": testRunUuid,
407-
"thBuildUuid": Cypress.env("BROWSERSTACK_TESTHUB_UUID"),
408-
"thJwtToken": Cypress.env("BROWSERSTACK_TESTHUB_JWT")
427+
"thBuildUuid": bstackBrowserValue("BROWSERSTACK_TESTHUB_UUID"),
428+
"thJwtToken": bstackBrowserValue("BROWSERSTACK_TESTHUB_JWT")
409429
};
410430
browserStackLog(`Payload to send: ${JSON.stringify(payloadToSend)}`);
411431

‎bin/accessibility-automation/plugin/index.js‎

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ const { decodeJWTToken } = require("../../helpers/utils");
33
const utils = require('../../helpers/utils');
44
const http = require('http');
55

6+
// Cypress 16 removed Cypress.env() from the browser. Values the support file needs are
7+
// written to config.expose (read by Cypress.expose(), Cypress >= 15.10) as well as config.env
8+
// (read by Cypress.env(), Cypress <= 15.x). Unknown config.expose is accepted by Cypress 15.8+
9+
// without error. [APS-22894]
10+
const exposeToBrowser = (config, key, value) => {
11+
config.env = config.env || {};
12+
config.env[key] = value;
13+
config.expose = config.expose || {};
14+
config.expose[key] = value;
15+
};
16+
617
process.env.BROWSERSTACK_ACCESSIBILITY_PLUGIN_LOADED = 'true';
718

819
const browserstackAccessibility = (on, config) => {
@@ -11,7 +22,7 @@ const browserstackAccessibility = (on, config) => {
1122
process.env.BROWSERSTACK_ACCESSIBILITY_PLUGIN_LOADED = 'true';
1223
let browser_validation = true;
1324
if (process.env.BROWSERSTACK_ACCESSIBILITY_DEBUG === 'true') {
14-
config.env.BROWSERSTACK_LOGS = 'true';
25+
exposeToBrowser(config, 'BROWSERSTACK_LOGS', 'true');
1526
process.env.BROWSERSTACK_LOGS = 'true';
1627
}
1728
on('task', {
@@ -99,18 +110,26 @@ const browserstackAccessibility = (on, config) => {
99110
} catch(err) {}
100111

101112
})
102-
config.env.ACCESSIBILITY_EXTENSION_PATH = process.env.ACCESSIBILITY_EXTENSION_PATH
103-
config.env.OS_VERSION = process.env.OS_VERSION
104-
config.env.OS = process.env.OS
105-
config.env.BROWSERSTACK_TESTHUB_UUID = process.env.BROWSERSTACK_TESTHUB_UUID
106-
config.env.BROWSERSTACK_TESTHUB_JWT = process.env.BROWSERSTACK_TESTHUB_JWT
107-
config.env.BROWSERSTACK_TESTHUB_API_PORT = process.env.BROWSERSTACK_TESTHUB_API_PORT
108-
config.env.REPORTER_API_PORT_NO = process.env.REPORTER_API_PORT_NO
113+
exposeToBrowser(config, 'ACCESSIBILITY_EXTENSION_PATH', process.env.ACCESSIBILITY_EXTENSION_PATH)
114+
exposeToBrowser(config, 'OS_VERSION', process.env.OS_VERSION)
115+
exposeToBrowser(config, 'OS', process.env.OS)
116+
exposeToBrowser(config, 'BROWSERSTACK_TESTHUB_UUID', process.env.BROWSERSTACK_TESTHUB_UUID)
117+
exposeToBrowser(config, 'BROWSERSTACK_TESTHUB_JWT', process.env.BROWSERSTACK_TESTHUB_JWT)
118+
exposeToBrowser(config, 'BROWSERSTACK_TESTHUB_API_PORT', process.env.BROWSERSTACK_TESTHUB_API_PORT)
119+
exposeToBrowser(config, 'REPORTER_API_PORT_NO', process.env.REPORTER_API_PORT_NO)
120+
121+
exposeToBrowser(config, 'IS_ACCESSIBILITY_EXTENSION_LOADED', browser_validation.toString())
109122

110-
config.env.IS_ACCESSIBILITY_EXTENSION_LOADED = browser_validation.toString()
123+
exposeToBrowser(config, 'INCLUDE_TAGS_FOR_ACCESSIBILITY', process.env.ACCESSIBILITY_INCLUDETAGSINTESTINGSCOPE)
124+
exposeToBrowser(config, 'EXCLUDE_TAGS_FOR_ACCESSIBILITY', process.env.ACCESSIBILITY_EXCLUDETAGSINTESTINGSCOPE)
111125

112-
config.env.INCLUDE_TAGS_FOR_ACCESSIBILITY = process.env.ACCESSIBILITY_INCLUDETAGSINTESTINGSCOPE
113-
config.env.EXCLUDE_TAGS_FOR_ACCESSIBILITY = process.env.ACCESSIBILITY_EXCLUDETAGSINTESTINGSCOPE
126+
// Customer-tunable keys arrive via config.env, which Cypress 16 no longer passes to the browser.
127+
const customerScanKeys = ['ACCESSIBILITY_SCAN_TIMEOUT', 'ACCESSIBILITY_SCAN_CIRCUIT_LIMIT'];
128+
customerScanKeys.forEach((key) => {
129+
if (config.env[key] !== undefined && config.expose[key] === undefined) {
130+
config.expose[key] = config.env[key];
131+
}
132+
});
114133

115134
return config;
116135
}

‎bin/helpers/capabilityHelper.js‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,35 @@ const logger = require("./logger").winstonLogger,
77
Utils = require("./utils"),
88
testhubUtils = require("../testhub/utils");
99

10+
const isAccessibilityOn = (bsConfig) =>
11+
process.env.BROWSERSTACK_TEST_ACCESSIBILITY === 'true' || String(bsConfig.run_settings.accessibility) === 'true';
12+
13+
const cypressMajor = (cypressVersion) => {
14+
const major = String(cypressVersion).match(/^(\d+)/);
15+
return major ? Number(major[1]) : undefined;
16+
};
17+
18+
const isAboveAccessibilityCypressMajor = (cypressVersion) => {
19+
const major = cypressMajor(cypressVersion);
20+
return major !== undefined && major > Constants.MAX_CYPRESS_MAJOR_FOR_ACCESSIBILITY;
21+
};
22+
23+
// True for an accessibility build on Cypress 16. Keyed on the major, not the requested version:
24+
// Rails runs the newest 16 it offers for any 16.x it doesn't list (e.g. 16.2.1, 16.3.0, "16.2"),
25+
// and that is 16.2.0 today, which has the extension service-worker bug (fixed in 16.2.1).
26+
// The version that actually runs is only known server-side, so this should move there
27+
// (terminalDeploy, next to the Cypress 16 network-logs/Local forceHttp1 rule) and be removed here.
28+
const needsForceHttp1ForAccessibility = (cypressVersion) =>
29+
cypressMajor(String(cypressVersion).trim()) === Constants.ACCESSIBILITY_FORCE_HTTP1_CYPRESS_MAJOR;
30+
31+
// Adds forceHttp1=true to the run's Cypress config unless the user already set forceHttp1
32+
// (either way), keeping every other key they passed.
33+
const withForceHttp1 = (config) => {
34+
const current = Utils.isUndefined(config) ? '' : String(config).trim();
35+
if (/(^|,)\s*forceHttp1\s*=/.test(current)) return config;
36+
return current ? `${current},forceHttp1=true` : 'forceHttp1=true';
37+
};
38+
1039
const caps = (bsConfig, zip) => {
1140
return new Promise(function (resolve, reject) {
1241
let user = undefined;
@@ -128,8 +157,27 @@ const caps = (bsConfig, zip) => {
128157
bsConfig.run_settings["accessibilityPlatforms"] = getAccessibilityPlatforms(bsConfig);
129158
}
130159

160+
// Tells Rails this CLI's support files read Cypress.expose(), so it may run Cypress 16+.
161+
bsConfig.run_settings["cypressExposeSupport"] = true;
162+
131163
// send run_settings as is for other capabilities
132-
obj.run_settings = JSON.stringify(bsConfig.run_settings);
164+
let runSettings = bsConfig.run_settings;
165+
// An accessibility build without a version asks for DEFAULT_CYPRESS_MAJOR_FOR_ACCESSIBILITY,
166+
// which keeps unpinned builds off the Cypress 16 forceHttp1 path (see constants.js).
167+
if (isAccessibilityOn(bsConfig) && Utils.isUndefined(runSettings.cypress_version)) {
168+
runSettings = Object.assign({}, runSettings, { cypress_version: String(Constants.DEFAULT_CYPRESS_MAJOR_FOR_ACCESSIBILITY) });
169+
logger.info(Constants.userMessages.ACCESSIBILITY_CYPRESS_VERSION_PINNED);
170+
}
171+
// Accessibility scans on the Cypress 16 that Rails runs today (16.2.0) only complete with forceHttp1.
172+
if (isAccessibilityOn(bsConfig) && !Utils.isUndefined(runSettings.cypress_version)
173+
&& needsForceHttp1ForAccessibility(runSettings.cypress_version)) {
174+
const config = withForceHttp1(runSettings.config);
175+
if (config !== runSettings.config) {
176+
runSettings = Object.assign({}, runSettings, { config });
177+
logger.info(Constants.userMessages.ACCESSIBILITY_FORCE_HTTP1_SET);
178+
}
179+
}
180+
obj.run_settings = JSON.stringify(runSettings);
133181
}
134182

135183
// The only route by which a cypress session can name its TestHub build: every session
@@ -220,6 +268,10 @@ const validate = (bsConfig, args) => {
220268

221269
if (!bsConfig.run_settings) reject(Constants.validationMessages.EMPTY_RUN_SETTINGS);
222270

271+
if (bsConfig.run_settings && isAccessibilityOn(bsConfig) && isAboveAccessibilityCypressMajor(bsConfig.run_settings.cypress_version)) {
272+
reject(Constants.validationMessages.ACCESSIBILITY_CYPRESS_VERSION_UNSUPPORTED);
273+
}
274+
223275
if (!bsConfig.run_settings.cypressConfigFilePath && !bsConfig.run_settings.userProvidedCypessConfigFile) {
224276
reject(Constants.validationMessages.EMPTY_CYPRESS_CONFIG_FILE);
225277
}

‎bin/helpers/constants.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ const userMessages = {
8686
FATAL_NETWORK_ERROR: `fatal: unable to access '${config.buildUrl}': Could not resolve host: ${config.rails_host}`,
8787
RETRY_LIMIT_EXCEEDED: `Max retries exceeded trying to connect to the host (retries: ${config.retries})`,
8888
CHECK_DASHBOARD_AT: "Please check the build status at: ",
89+
ACCESSIBILITY_CYPRESS_VERSION_PINNED:
90+
"Accessibility builds without a cypress_version run on the latest Cypress 15.",
91+
ACCESSIBILITY_FORCE_HTTP1_SET:
92+
"Accessibility on Cypress 16 runs on Cypress 16.2.0, which needs Cypress's HTTP/1.1 proxy, so this build runs with forceHttp1=true.",
8993
CYPRESS_VERSION_CHANGED:
9094
"Your build will run using Cypress <actualVersion> instead of Cypress <preferredVersion>.<frameworkUpgradeMessage> Read more about supported versions here: http://browserstack.com/docs/automate/cypress/supported-versions",
9195
LOCAL_START_FAILED: "Local Testing setup failed.",
@@ -198,6 +202,8 @@ const validationMessages = {
198202
"You have specified '--record' flag but you've not provided the '--record-key' and we could not find any value in 'CYPRESS_RECORD_KEY' environment variable. Your record functionality on cypress.io dashboard might not work as it needs the key and projectId",
199203
NODE_VERSION_PARSING_ERROR:
200204
"We weren't able to successfully parse the specified nodeVersion. We will be using the default nodeVersion to run your tests.",
205+
ACCESSIBILITY_CYPRESS_VERSION_UNSUPPORTED:
206+
"Accessibility Testing supports Cypress up to version 16. Set cypress_version to 16 or lower in browserstack.json, or turn off accessibility to run a later Cypress.",
201207
AUTO_IMPORT_CONFLICT_ERROR:
202208
"Cannot use both 'auto_import_dev_dependencies' and manual npm dependency configuration. Please either set 'auto_import_dev_dependencies' to false or remove manual 'npm_dependencies', 'win_npm_dependencies', and 'mac_npm_dependencies' configurations.",
203209
AUTO_IMPORT_INVALID_TYPE:
@@ -443,6 +449,19 @@ const REDACTED_AUTH = `auth: { "username": ${REDACTED}, "access_key": ${REDACTED
443449

444450
const SPEC_TIMEOUT_LIMIT = 120; // IN MINS
445451

452+
// Newest Cypress major accessibility runs on (APS-22894). Raising this needs no Rails change.
453+
const MAX_CYPRESS_MAJOR_FOR_ACCESSIBILITY = 16;
454+
// Major an accessibility build asks for when it names no cypress_version. This CLI's choice, not
455+
// Rails': for a CLI that sends cypressExposeSupport, Rails defaults to its newest Cypress (16).
456+
// Kept on 15 so unpinned accessibility builds stay off the Cypress 16 forceHttp1 path.
457+
const DEFAULT_CYPRESS_MAJOR_FOR_ACCESSIBILITY = 15;
458+
// Cypress major whose accessibility builds get forceHttp1. On 16.1.0-16.2.0 the a11y extension's
459+
// service worker never starts, so every scan times out unless forceHttp1 is on. Regression from
460+
// cypress-io/cypress#34762 (16.1.0), reported as cypress-io/cypress#35127, fixed by #34958 in 16.2.1.
461+
// Whole major, because Rails runs 16.2.0 for every 16.x request while it is the only 16 it offers.
462+
// SDK-8048 preprod A/B on 16.2.0: scan step 25.6s without forceHttp1, 4.2s with it.
463+
const ACCESSIBILITY_FORCE_HTTP1_CYPRESS_MAJOR = 16;
464+
446465
const CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY = "custom_errors_to_print";
447466

448467
const CYPRESS_V9_AND_OLDER_TYPE = "CYPRESS_V9_AND_OLDER_TYPE";
@@ -508,6 +527,9 @@ module.exports = Object.freeze({
508527
REDACTED,
509528
BUILD_FAILED_EXIT_CODE,
510529
SPEC_TIMEOUT_LIMIT,
530+
MAX_CYPRESS_MAJOR_FOR_ACCESSIBILITY,
531+
DEFAULT_CYPRESS_MAJOR_FOR_ACCESSIBILITY,
532+
ACCESSIBILITY_FORCE_HTTP1_CYPRESS_MAJOR,
511533
CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY,
512534
CYPRESS_V9_AND_OLDER_TYPE,
513535
CYPRESS_V10_AND_ABOVE_TYPE,

‎bin/helpers/utils.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ exports.getErrorCodeFromMsg = (errMsg) => {
109109
case Constants.validationMessages.INVALID_GEO_LOCATION:
110110
errorCode = 'invalid_geo_location';
111111
break;
112+
case Constants.validationMessages.ACCESSIBILITY_CYPRESS_VERSION_UNSUPPORTED:
113+
errorCode = 'accessibility_cypress_version_unsupported';
114+
break;
112115
case Constants.validationMessages.NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE:
113116
errorCode = 'not_allowed_geo_location_and_local_mode';
114117
break;

‎bin/testObservability/cypress/index.js‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
/* Event listeners + custom commands for Cypress */
22

3+
/*
4+
* Cypress 16 removed Cypress.env() from the browser; values set by the Node plugin now reach
5+
* the browser through config.expose / Cypress.expose() (available from Cypress 15.10). The
6+
* plugin writes every value to both config.env and config.expose, so read expose first and
7+
* fall back to Cypress.env() for Cypress <= 15.x, where expose does not exist yet. [APS-22894]
8+
*/
9+
const bstackBrowserValue = (key) => {
10+
try {
11+
if (typeof Cypress.expose === 'function') {
12+
const exposed = Cypress.expose(key);
13+
if (exposed !== undefined && exposed !== null) return exposed;
14+
}
15+
} catch (e) {}
16+
try {
17+
return Cypress.env(key);
18+
} catch (e) {
19+
return undefined;
20+
}
21+
};
22+
323
/* Used to detect Gherkin steps */
424
const STEP_KEYWORDS = ['given', 'when', 'then', 'and', 'but', '*'];
525

@@ -42,20 +62,20 @@ const sanitizeForTask = (data) => {
4262

4363
const browserStackLog = (message) => {
4464

45-
if (!Cypress.env('BROWSERSTACK_LOGS')) return;
65+
if (!bstackBrowserValue('BROWSERSTACK_LOGS')) return;
4666
cy.task('browserstack_log', message);
4767
}
4868

4969
const shouldSkipCommand = (command) => {
50-
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
70+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) {
5171
return true;
5272
}
5373
/* the batch task is filtered too, else each dispatch refills the queue */
5474
return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command', 'test_observability_batch', 'browserstack_log', 'test_observability_log'].some(event => command.attributes.args.includes(event))));
5575
}
5676

5777
Cypress.on('log:changed', (attrs) => {
58-
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) return;
78+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) return;
5979
if (!attrs) return;
6080
if (!attrs.createdAtTimestamp || !attrs.updatedAtTimestamp) return;
6181
if (attrs.state !== 'passed' && attrs.state !== 'failed') return;
@@ -237,7 +257,7 @@ Cypress.on('command:end', (command) => {
237257
});
238258

239259
Cypress.on('command:enqueued', (attrs) => {
240-
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) return;
260+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) return;
241261
if (!attrs || attrs.name !== 'log') return;
242262
const args = attrs.args || [];
243263
if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
@@ -420,7 +440,7 @@ const flushEventsQueue = () => {
420440
beforeEach(() => {
421441
/* browserstack internal helper hook */
422442

423-
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
443+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) {
424444
return;
425445
}
426446

@@ -430,7 +450,7 @@ beforeEach(() => {
430450

431451
afterEach(function() {
432452
/* browserstack internal helper hook */
433-
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) {
453+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) {
434454
return;
435455
}
436456

0 commit comments

Comments
 (0)