browserstack-cypress-cli 1.38.1-tp.0 → 1.38.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.
package/bin/commands/runs.js
CHANGED
|
@@ -106,6 +106,12 @@ module.exports = function run(args, rawArgs) {
|
|
|
106
106
|
|
|
107
107
|
// set spec timeout
|
|
108
108
|
utils.setSpecTimeout(bsConfig, args);
|
|
109
|
+
|
|
110
|
+
// run test in headed mode
|
|
111
|
+
utils.setHeaded(bsConfig, args);
|
|
112
|
+
|
|
113
|
+
//set browsers
|
|
114
|
+
await utils.setBrowsers(bsConfig, args);
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
|
|
@@ -127,6 +133,29 @@ module.exports = function run(args, rawArgs) {
|
|
|
127
133
|
isAccessibilitySession = false;
|
|
128
134
|
}
|
|
129
135
|
|
|
136
|
+
// Headless mode and non-Chrome browsers cannot run Accessibility scans; if no platform can,
|
|
137
|
+
// drop accessibility before build start so no Accessibility build is registered.
|
|
138
|
+
// Decide with accessibility on at the root, as checkAndSetAccessibility will set it, so a
|
|
139
|
+
// request made only on a browser entry survives a --browser override. Warn only for the
|
|
140
|
+
// platforms the user asked for: entries without a flag count only when accessibility is on at
|
|
141
|
+
// the root or no entry sets one (a --browser override drops the entries' own flags).
|
|
142
|
+
if (isAccessibilitySession && isBrowserstackInfra) {
|
|
143
|
+
try {
|
|
144
|
+
const withRootAccessibility = (accessibility) => Object.assign({}, bsConfig, {
|
|
145
|
+
run_settings: Object.assign({}, bsConfig.run_settings, { accessibility }),
|
|
146
|
+
});
|
|
147
|
+
const hasBrowserLevelFlag = (bsConfig.browsers || []).some((browser) => browser.accessibility !== undefined);
|
|
148
|
+
const requestedRoot = String(bsConfig.run_settings.accessibility) === 'true' || !hasBrowserLevelFlag;
|
|
149
|
+
capabilityHelper.getAccessibilityPlatforms(withRootAccessibility(requestedRoot));
|
|
150
|
+
if (!capabilityHelper.getAccessibilityPlatforms(withRootAccessibility(true), false).some((platform) => String(platform) === 'true')) {
|
|
151
|
+
logger.debug('Accessibility disabled for the build as no platform supports it');
|
|
152
|
+
isAccessibilitySession = false;
|
|
153
|
+
}
|
|
154
|
+
} catch (err) {
|
|
155
|
+
logger.debug(`Unable to resolve accessibility platforms: ${err}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
130
159
|
checkAndSetAccessibility(bsConfig, isAccessibilitySession);
|
|
131
160
|
|
|
132
161
|
const preferredPort = 5348;
|
|
@@ -160,9 +189,6 @@ module.exports = function run(args, rawArgs) {
|
|
|
160
189
|
// set Local Config File
|
|
161
190
|
utils.setLocalConfigFile(bsConfig, args);
|
|
162
191
|
|
|
163
|
-
// run test in headed mode
|
|
164
|
-
utils.setHeaded(bsConfig, args);
|
|
165
|
-
|
|
166
192
|
// set the no-wrap
|
|
167
193
|
utils.setNoWrap(bsConfig, args);
|
|
168
194
|
|
|
@@ -197,9 +223,6 @@ module.exports = function run(args, rawArgs) {
|
|
|
197
223
|
// set node version
|
|
198
224
|
utils.setNodeVersion(bsConfig, args);
|
|
199
225
|
|
|
200
|
-
//set browsers
|
|
201
|
-
await utils.setBrowsers(bsConfig, args);
|
|
202
|
-
|
|
203
226
|
//set config (--config)
|
|
204
227
|
utils.setConfig(bsConfig, args);
|
|
205
228
|
|
|
@@ -154,7 +154,7 @@ const caps = (bsConfig, zip) => {
|
|
|
154
154
|
if (process.env.BROWSERSTACK_TEST_ACCESSIBILITY === 'true') {
|
|
155
155
|
// If any of the platform has accessibility true, make it true
|
|
156
156
|
bsConfig.run_settings["accessibility"] = true;
|
|
157
|
-
bsConfig.run_settings["accessibilityPlatforms"] = getAccessibilityPlatforms(bsConfig);
|
|
157
|
+
bsConfig.run_settings["accessibilityPlatforms"] = getAccessibilityPlatforms(bsConfig, false);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
// Tells Rails this CLI's support files read Cypress.expose(), so it may run Cypress 16+.
|
|
@@ -213,11 +213,11 @@ const caps = (bsConfig, zip) => {
|
|
|
213
213
|
resolve(data);
|
|
214
214
|
})
|
|
215
215
|
}
|
|
216
|
-
const getAccessibilityPlatforms = (bsConfig) => {
|
|
216
|
+
const getAccessibilityPlatforms = (bsConfig, logWarnings = true) => {
|
|
217
217
|
const browserList = [];
|
|
218
218
|
if (bsConfig.browsers) {
|
|
219
219
|
bsConfig.browsers.forEach((element) => {
|
|
220
|
-
element.versions.forEach((version) => {
|
|
220
|
+
(element.versions || []).forEach((version) => {
|
|
221
221
|
browserList.push({...element, version, platform: element.os + "-" + element.browser});
|
|
222
222
|
});
|
|
223
223
|
});
|
|
@@ -228,14 +228,22 @@ const getAccessibilityPlatforms = (bsConfig) => {
|
|
|
228
228
|
if (!Utils.isUndefined(bsConfig.run_settings.accessibility)) {
|
|
229
229
|
rootLevelAccessibility = bsConfig.run_settings.accessibility.toString() === 'true';
|
|
230
230
|
}
|
|
231
|
+
const isHeaded = !Utils.isUndefined(bsConfig.run_settings.headless) && String(bsConfig.run_settings.headless) === "false";
|
|
231
232
|
browserList.forEach((browserDetails, idx) => {
|
|
232
233
|
accessibilityPlatforms[idx] = (browserDetails.accessibility === undefined) ? rootLevelAccessibility : browserDetails.accessibility;
|
|
233
|
-
if (
|
|
234
|
-
|
|
234
|
+
if (String(accessibilityPlatforms[idx]) !== 'true') return;
|
|
235
|
+
|
|
236
|
+
let reason = null;
|
|
237
|
+
if (!isHeaded) {
|
|
238
|
+
reason = `Accessibility Automation does not run in headless mode. Set "headless": false in run_settings or pass --headed to run Accessibility scans.`;
|
|
235
239
|
} else if (browserDetails.browser && browserDetails.browser.toLowerCase() !== 'chrome') {
|
|
236
|
-
|
|
237
|
-
} else if (browserDetails.version && !browserDetails.version.includes('latest') && browserDetails.version <= 94) {
|
|
238
|
-
|
|
240
|
+
reason = `Accessibility Automation runs only on Chrome browsers.`;
|
|
241
|
+
} else if (browserDetails.version && !String(browserDetails.version).includes('latest') && browserDetails.version <= 94) {
|
|
242
|
+
reason = `Accessibility Automation runs only on Chrome browser versions greater than 94.`;
|
|
243
|
+
}
|
|
244
|
+
if (reason) {
|
|
245
|
+
accessibilityPlatforms[idx] = false;
|
|
246
|
+
if (logWarnings) logger.warn(`Accessibility Automation has been disabled for ${browserDetails.platform}. ${reason}`);
|
|
239
247
|
}
|
|
240
248
|
});
|
|
241
249
|
return accessibilityPlatforms;
|
|
@@ -432,5 +440,6 @@ const validate = (bsConfig, args) => {
|
|
|
432
440
|
module.exports = {
|
|
433
441
|
caps,
|
|
434
442
|
addCypressZipStartLocation,
|
|
443
|
+
getAccessibilityPlatforms,
|
|
435
444
|
validate
|
|
436
445
|
}
|
|
@@ -451,6 +451,10 @@ class MyReporter {
|
|
|
451
451
|
}
|
|
452
452
|
};
|
|
453
453
|
|
|
454
|
+
if(eventType.match(/TestRun/)) {
|
|
455
|
+
testData.tags = this.tags(test);
|
|
456
|
+
}
|
|
457
|
+
|
|
454
458
|
debugOnConsole(`${eventType} for uuid: ${testData.uuid}`);
|
|
455
459
|
|
|
456
460
|
this.mapTestId(testData, eventType);
|
|
@@ -875,6 +879,29 @@ class MyReporter {
|
|
|
875
879
|
return titlePath.slice(0, titlePath.length - 1)
|
|
876
880
|
}
|
|
877
881
|
|
|
882
|
+
// Tags come from the it()/describe() config. Newer Cypress sends it resolved as
|
|
883
|
+
// { testConfigList: [{ overrides }, ...] }, one entry per level; older versions send the raw overrides.
|
|
884
|
+
tags(test) {
|
|
885
|
+
try {
|
|
886
|
+
const testConfig = test && test._testConfig;
|
|
887
|
+
if (!testConfig) return [];
|
|
888
|
+
const overridesList = Array.isArray(testConfig.testConfigList)
|
|
889
|
+
? testConfig.testConfigList.map((entry) => entry && entry.overrides)
|
|
890
|
+
: [testConfig];
|
|
891
|
+
const tags = [];
|
|
892
|
+
overridesList.forEach((overrides) => {
|
|
893
|
+
const value = overrides && overrides.tags;
|
|
894
|
+
(Array.isArray(value) ? value : [value]).forEach((tag) => {
|
|
895
|
+
const name = typeof tag === 'string' ? tag.trim() : '';
|
|
896
|
+
if (name && !tags.includes(name)) tags.push(name);
|
|
897
|
+
});
|
|
898
|
+
});
|
|
899
|
+
return tags;
|
|
900
|
+
} catch (e) {
|
|
901
|
+
return [];
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
878
905
|
// Recursively find the root parent, and return the parents file
|
|
879
906
|
// This is required as test.file can be undefined in some tests on cypress
|
|
880
907
|
getRootParentFile(test) {
|