browserstack-cypress-cli 1.37.5 → 1.38.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/bin/accessibility-automation/cypress/index.js +35 -15
- package/bin/accessibility-automation/plugin/index.js +30 -11
- package/bin/helpers/capabilityHelper.js +53 -1
- package/bin/helpers/constants.js +22 -0
- package/bin/helpers/utils.js +3 -0
- package/bin/testObservability/cypress/index.js +26 -6
- package/bin/testObservability/plugin/index.js +12 -1
- package/package.json +1 -1
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
/* Event listeners + custom commands for Cypress */
|
|
2
2
|
|
|
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
|
+
|
|
3
23
|
const browserStackLog = (message) => {
|
|
4
|
-
if (!
|
|
24
|
+
if (!bstackBrowserValue('BROWSERSTACK_LOGS')) return;
|
|
5
25
|
cy.task('browserstack_log', message);
|
|
6
26
|
}
|
|
7
27
|
|
|
@@ -13,7 +33,7 @@ const browserStackLog = (message) => {
|
|
|
13
33
|
let consecutiveA11yTimeouts = 0;
|
|
14
34
|
let a11yCircuitOpen = false;
|
|
15
35
|
let a11yCircuitLogged = false;
|
|
16
|
-
const getA11yCircuitLimit = () => parseInt(
|
|
36
|
+
const getA11yCircuitLimit = () => parseInt(bstackBrowserValue('ACCESSIBILITY_SCAN_CIRCUIT_LIMIT')) || 3;
|
|
17
37
|
const noteA11yTimeout = () => {
|
|
18
38
|
consecutiveA11yTimeouts += 1;
|
|
19
39
|
if (!a11yCircuitOpen && consecutiveA11yTimeouts >= getA11yCircuitLimit()) {
|
|
@@ -76,7 +96,7 @@ new Promise((resolve) => {
|
|
|
76
96
|
}
|
|
77
97
|
let settled = false;
|
|
78
98
|
const finish = (val) => { if (!settled) { settled = true; clearTimeout(overallTimer); resolve(val); } };
|
|
79
|
-
const overallTimeout = parseInt(
|
|
99
|
+
const overallTimeout = parseInt(bstackBrowserValue('ACCESSIBILITY_SCAN_TIMEOUT')) || 25000;
|
|
80
100
|
const overallTimer = setTimeout(() => { noteA11yTimeout(); finish("Accessibility scan timed out"); }, overallTimeout);
|
|
81
101
|
|
|
82
102
|
try {
|
|
@@ -252,7 +272,7 @@ new Promise((resolve) => {
|
|
|
252
272
|
}
|
|
253
273
|
let settled = false;
|
|
254
274
|
const finish = (val) => { if (!settled) { settled = true; clearTimeout(overallTimer); resolve(val); } };
|
|
255
|
-
const overallTimeout = parseInt(
|
|
275
|
+
const overallTimeout = parseInt(bstackBrowserValue('ACCESSIBILITY_SCAN_TIMEOUT')) || 25000;
|
|
256
276
|
const overallTimer = setTimeout(() => { noteA11yTimeout(); finish("Accessibility results save timed out"); }, overallTimeout);
|
|
257
277
|
try {
|
|
258
278
|
const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
|
|
@@ -314,24 +334,24 @@ new Promise((resolve) => {
|
|
|
314
334
|
})
|
|
315
335
|
|
|
316
336
|
const shouldScanForAccessibility = (attributes) => {
|
|
317
|
-
if (
|
|
337
|
+
if (bstackBrowserValue("IS_ACCESSIBILITY_EXTENSION_LOADED") !== "true") return false;
|
|
318
338
|
|
|
319
|
-
const extensionPath =
|
|
339
|
+
const extensionPath = bstackBrowserValue("ACCESSIBILITY_EXTENSION_PATH");
|
|
320
340
|
const isHeaded = Cypress.browser.isHeaded;
|
|
321
341
|
|
|
322
342
|
if (!isHeaded || (extensionPath === undefined)) return false;
|
|
323
343
|
|
|
324
344
|
let shouldScanTestForAccessibility = true;
|
|
325
345
|
|
|
326
|
-
if (
|
|
346
|
+
if (bstackBrowserValue("INCLUDE_TAGS_FOR_ACCESSIBILITY") || bstackBrowserValue("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
327
347
|
try {
|
|
328
348
|
let includeTagArray = [];
|
|
329
349
|
let excludeTagArray = [];
|
|
330
|
-
if (
|
|
331
|
-
includeTagArray =
|
|
350
|
+
if (bstackBrowserValue("INCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
351
|
+
includeTagArray = bstackBrowserValue("INCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
|
|
332
352
|
}
|
|
333
|
-
if (
|
|
334
|
-
excludeTagArray =
|
|
353
|
+
if (bstackBrowserValue("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
354
|
+
excludeTagArray = bstackBrowserValue("EXCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
|
|
335
355
|
}
|
|
336
356
|
|
|
337
357
|
const fullTestName = attributes.title;
|
|
@@ -383,8 +403,8 @@ afterEach(() => {
|
|
|
383
403
|
cy.wrap(performScan(win), {timeout: 30000}).then(() => {
|
|
384
404
|
try {
|
|
385
405
|
let os_data;
|
|
386
|
-
if (
|
|
387
|
-
os_data =
|
|
406
|
+
if (bstackBrowserValue("OS")) {
|
|
407
|
+
os_data = bstackBrowserValue("OS");
|
|
388
408
|
} else {
|
|
389
409
|
os_data = Cypress.platform === 'linux' ? 'mac' : "win"
|
|
390
410
|
}
|
|
@@ -404,8 +424,8 @@ afterEach(() => {
|
|
|
404
424
|
|
|
405
425
|
const payloadToSend = {
|
|
406
426
|
"thTestRunUuid": testRunUuid,
|
|
407
|
-
"thBuildUuid":
|
|
408
|
-
"thJwtToken":
|
|
427
|
+
"thBuildUuid": bstackBrowserValue("BROWSERSTACK_TESTHUB_UUID"),
|
|
428
|
+
"thJwtToken": bstackBrowserValue("BROWSERSTACK_TESTHUB_JWT")
|
|
409
429
|
};
|
|
410
430
|
browserStackLog(`Payload to send: ${JSON.stringify(payloadToSend)}`);
|
|
411
431
|
|
|
@@ -3,6 +3,17 @@ const { decodeJWTToken } = require("../../helpers/utils");
|
|
|
3
3
|
const utils = require('../../helpers/utils');
|
|
4
4
|
const http = require('http');
|
|
5
5
|
|
|
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
|
+
|
|
6
17
|
process.env.BROWSERSTACK_ACCESSIBILITY_PLUGIN_LOADED = 'true';
|
|
7
18
|
|
|
8
19
|
const browserstackAccessibility = (on, config) => {
|
|
@@ -11,7 +22,7 @@ const browserstackAccessibility = (on, config) => {
|
|
|
11
22
|
process.env.BROWSERSTACK_ACCESSIBILITY_PLUGIN_LOADED = 'true';
|
|
12
23
|
let browser_validation = true;
|
|
13
24
|
if (process.env.BROWSERSTACK_ACCESSIBILITY_DEBUG === 'true') {
|
|
14
|
-
config
|
|
25
|
+
exposeToBrowser(config, 'BROWSERSTACK_LOGS', 'true');
|
|
15
26
|
process.env.BROWSERSTACK_LOGS = 'true';
|
|
16
27
|
}
|
|
17
28
|
on('task', {
|
|
@@ -99,18 +110,26 @@ const browserstackAccessibility = (on, config) => {
|
|
|
99
110
|
} catch(err) {}
|
|
100
111
|
|
|
101
112
|
})
|
|
102
|
-
config
|
|
103
|
-
config
|
|
104
|
-
config
|
|
105
|
-
config
|
|
106
|
-
config
|
|
107
|
-
config
|
|
108
|
-
config
|
|
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())
|
|
109
122
|
|
|
110
|
-
config.env.
|
|
123
|
+
exposeToBrowser(config, 'INCLUDE_TAGS_FOR_ACCESSIBILITY', process.env.ACCESSIBILITY_INCLUDETAGSINTESTINGSCOPE)
|
|
124
|
+
exposeToBrowser(config, 'EXCLUDE_TAGS_FOR_ACCESSIBILITY', process.env.ACCESSIBILITY_EXCLUDETAGSINTESTINGSCOPE)
|
|
111
125
|
|
|
112
|
-
config.env
|
|
113
|
-
|
|
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
|
+
});
|
|
114
133
|
|
|
115
134
|
return config;
|
|
116
135
|
}
|
|
@@ -7,6 +7,35 @@ const logger = require("./logger").winstonLogger,
|
|
|
7
7
|
Utils = require("./utils"),
|
|
8
8
|
testhubUtils = require("../testhub/utils");
|
|
9
9
|
|
|
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
|
+
|
|
10
39
|
const caps = (bsConfig, zip) => {
|
|
11
40
|
return new Promise(function (resolve, reject) {
|
|
12
41
|
let user = undefined;
|
|
@@ -128,8 +157,27 @@ const caps = (bsConfig, zip) => {
|
|
|
128
157
|
bsConfig.run_settings["accessibilityPlatforms"] = getAccessibilityPlatforms(bsConfig);
|
|
129
158
|
}
|
|
130
159
|
|
|
160
|
+
// Tells Rails this CLI's support files read Cypress.expose(), so it may run Cypress 16+.
|
|
161
|
+
bsConfig.run_settings["cypressExposeSupport"] = true;
|
|
162
|
+
|
|
131
163
|
// send run_settings as is for other capabilities
|
|
132
|
-
|
|
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);
|
|
133
181
|
}
|
|
134
182
|
|
|
135
183
|
// The only route by which a cypress session can name its TestHub build: every session
|
|
@@ -220,6 +268,10 @@ const validate = (bsConfig, args) => {
|
|
|
220
268
|
|
|
221
269
|
if (!bsConfig.run_settings) reject(Constants.validationMessages.EMPTY_RUN_SETTINGS);
|
|
222
270
|
|
|
271
|
+
if (bsConfig.run_settings && isAccessibilityOn(bsConfig) && isAboveAccessibilityCypressMajor(bsConfig.run_settings.cypress_version)) {
|
|
272
|
+
reject(Constants.validationMessages.ACCESSIBILITY_CYPRESS_VERSION_UNSUPPORTED);
|
|
273
|
+
}
|
|
274
|
+
|
|
223
275
|
if (!bsConfig.run_settings.cypressConfigFilePath && !bsConfig.run_settings.userProvidedCypessConfigFile) {
|
|
224
276
|
reject(Constants.validationMessages.EMPTY_CYPRESS_CONFIG_FILE);
|
|
225
277
|
}
|
package/bin/helpers/constants.js
CHANGED
|
@@ -86,6 +86,10 @@ const userMessages = {
|
|
|
86
86
|
FATAL_NETWORK_ERROR: `fatal: unable to access '${config.buildUrl}': Could not resolve host: ${config.rails_host}`,
|
|
87
87
|
RETRY_LIMIT_EXCEEDED: `Max retries exceeded trying to connect to the host (retries: ${config.retries})`,
|
|
88
88
|
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.",
|
|
89
93
|
CYPRESS_VERSION_CHANGED:
|
|
90
94
|
"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",
|
|
91
95
|
LOCAL_START_FAILED: "Local Testing setup failed.",
|
|
@@ -198,6 +202,8 @@ const validationMessages = {
|
|
|
198
202
|
"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",
|
|
199
203
|
NODE_VERSION_PARSING_ERROR:
|
|
200
204
|
"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.",
|
|
201
207
|
AUTO_IMPORT_CONFLICT_ERROR:
|
|
202
208
|
"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.",
|
|
203
209
|
AUTO_IMPORT_INVALID_TYPE:
|
|
@@ -443,6 +449,19 @@ const REDACTED_AUTH = `auth: { "username": ${REDACTED}, "access_key": ${REDACTED
|
|
|
443
449
|
|
|
444
450
|
const SPEC_TIMEOUT_LIMIT = 120; // IN MINS
|
|
445
451
|
|
|
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
|
+
|
|
446
465
|
const CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY = "custom_errors_to_print";
|
|
447
466
|
|
|
448
467
|
const CYPRESS_V9_AND_OLDER_TYPE = "CYPRESS_V9_AND_OLDER_TYPE";
|
|
@@ -508,6 +527,9 @@ module.exports = Object.freeze({
|
|
|
508
527
|
REDACTED,
|
|
509
528
|
BUILD_FAILED_EXIT_CODE,
|
|
510
529
|
SPEC_TIMEOUT_LIMIT,
|
|
530
|
+
MAX_CYPRESS_MAJOR_FOR_ACCESSIBILITY,
|
|
531
|
+
DEFAULT_CYPRESS_MAJOR_FOR_ACCESSIBILITY,
|
|
532
|
+
ACCESSIBILITY_FORCE_HTTP1_CYPRESS_MAJOR,
|
|
511
533
|
CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY,
|
|
512
534
|
CYPRESS_V9_AND_OLDER_TYPE,
|
|
513
535
|
CYPRESS_V10_AND_ABOVE_TYPE,
|
package/bin/helpers/utils.js
CHANGED
|
@@ -109,6 +109,9 @@ exports.getErrorCodeFromMsg = (errMsg) => {
|
|
|
109
109
|
case Constants.validationMessages.INVALID_GEO_LOCATION:
|
|
110
110
|
errorCode = 'invalid_geo_location';
|
|
111
111
|
break;
|
|
112
|
+
case Constants.validationMessages.ACCESSIBILITY_CYPRESS_VERSION_UNSUPPORTED:
|
|
113
|
+
errorCode = 'accessibility_cypress_version_unsupported';
|
|
114
|
+
break;
|
|
112
115
|
case Constants.validationMessages.NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE:
|
|
113
116
|
errorCode = 'not_allowed_geo_location_and_local_mode';
|
|
114
117
|
break;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
/* Event listeners + custom commands for Cypress */
|
|
2
2
|
|
|
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
|
+
|
|
3
23
|
/* Used to detect Gherkin steps */
|
|
4
24
|
const STEP_KEYWORDS = ['given', 'when', 'then', 'and', 'but', '*'];
|
|
5
25
|
|
|
@@ -42,12 +62,12 @@ const sanitizeForTask = (data) => {
|
|
|
42
62
|
|
|
43
63
|
const browserStackLog = (message) => {
|
|
44
64
|
|
|
45
|
-
if (!
|
|
65
|
+
if (!bstackBrowserValue('BROWSERSTACK_LOGS')) return;
|
|
46
66
|
cy.task('browserstack_log', message);
|
|
47
67
|
}
|
|
48
68
|
|
|
49
69
|
const shouldSkipCommand = (command) => {
|
|
50
|
-
if (!
|
|
70
|
+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) {
|
|
51
71
|
return true;
|
|
52
72
|
}
|
|
53
73
|
/* the batch task is filtered too, else each dispatch refills the queue */
|
|
@@ -55,7 +75,7 @@ const shouldSkipCommand = (command) => {
|
|
|
55
75
|
}
|
|
56
76
|
|
|
57
77
|
Cypress.on('log:changed', (attrs) => {
|
|
58
|
-
if (!
|
|
78
|
+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) return;
|
|
59
79
|
if (!attrs) return;
|
|
60
80
|
if (!attrs.createdAtTimestamp || !attrs.updatedAtTimestamp) return;
|
|
61
81
|
if (attrs.state !== 'passed' && attrs.state !== 'failed') return;
|
|
@@ -237,7 +257,7 @@ Cypress.on('command:end', (command) => {
|
|
|
237
257
|
});
|
|
238
258
|
|
|
239
259
|
Cypress.on('command:enqueued', (attrs) => {
|
|
240
|
-
if (!
|
|
260
|
+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) return;
|
|
241
261
|
if (!attrs || attrs.name !== 'log') return;
|
|
242
262
|
const args = attrs.args || [];
|
|
243
263
|
if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
|
|
@@ -420,7 +440,7 @@ const flushEventsQueue = () => {
|
|
|
420
440
|
beforeEach(() => {
|
|
421
441
|
/* browserstack internal helper hook */
|
|
422
442
|
|
|
423
|
-
if (!
|
|
443
|
+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) {
|
|
424
444
|
return;
|
|
425
445
|
}
|
|
426
446
|
|
|
@@ -430,7 +450,7 @@ beforeEach(() => {
|
|
|
430
450
|
|
|
431
451
|
afterEach(function() {
|
|
432
452
|
/* browserstack internal helper hook */
|
|
433
|
-
if (!
|
|
453
|
+
if (!bstackBrowserValue('BROWSERSTACK_O11Y_LOGS')) {
|
|
434
454
|
return;
|
|
435
455
|
}
|
|
436
456
|
|
|
@@ -2,10 +2,21 @@ const ipc = require('node-ipc');
|
|
|
2
2
|
const { connectIPCClient } = require('./ipcClient');
|
|
3
3
|
const { IPC_EVENTS } = require('../helper/constants');
|
|
4
4
|
|
|
5
|
+
// Cypress 16 removed Cypress.env() from the browser. Values the support file needs are
|
|
6
|
+
// written to config.expose (read by Cypress.expose(), Cypress >= 15.10) as well as config.env
|
|
7
|
+
// (read by Cypress.env(), Cypress <= 15.x). Unknown config.expose is accepted by Cypress 15.8+
|
|
8
|
+
// without error. [APS-22894]
|
|
9
|
+
const exposeToBrowser = (config, key, value) => {
|
|
10
|
+
config.env = config.env || {};
|
|
11
|
+
config.env[key] = value;
|
|
12
|
+
config.expose = config.expose || {};
|
|
13
|
+
config.expose[key] = value;
|
|
14
|
+
};
|
|
15
|
+
|
|
5
16
|
const browserstackTestObservabilityPlugin = (on, config, callbacks) => {
|
|
6
17
|
|
|
7
18
|
try {
|
|
8
|
-
config
|
|
19
|
+
exposeToBrowser(config, 'BROWSERSTACK_O11Y_LOGS', 'true');
|
|
9
20
|
process.env.BROWSERSTACK_O11Y_LOGS = 'true';
|
|
10
21
|
} catch (err) {}
|
|
11
22
|
|