browserstack-cypress-cli 1.31.10 → 1.32.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.
@@ -1,383 +1,381 @@
1
1
  /* Event listeners + custom commands for Cypress */
2
2
 
3
3
  const browserStackLog = (message) => {
4
- if (!Cypress.env('BROWSERSTACK_LOGS')) return;
5
- cy.task('browserstack_log', message);
6
- }
7
-
4
+ if (!Cypress.env('BROWSERSTACK_LOGS')) return;
5
+ cy.task('browserstack_log', message);
6
+ }
7
+
8
8
  const commandsToWrap = ['visit', 'click', 'type', 'request', 'dblclick', 'rightclick', 'clear', 'check', 'uncheck', 'select', 'trigger', 'selectFile', 'scrollIntoView', 'scroll', 'scrollTo', 'blur', 'focus', 'go', 'reload', 'submit', 'viewport', 'origin'];
9
9
 
10
10
  const performScan = (win, payloadToSend) =>
11
- new Promise(async (resolve, reject) => {
11
+ new Promise(async (resolve, reject) => {
12
12
  const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
13
13
  if (!isHttpOrHttps) {
14
- resolve();
14
+ resolve();
15
15
  }
16
16
 
17
17
  function findAccessibilityAutomationElement() {
18
- return win.document.querySelector("#accessibility-automation-element");
18
+ return win.document.querySelector("#accessibility-automation-element");
19
19
  }
20
20
 
21
21
  function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
22
- return new Promise(async (resolve, reject) => {
22
+ return new Promise(async (resolve, reject) => {
23
23
  let count = 0;
24
24
  const intervalID = setInterval(async () => {
25
- if (count > retryCount) {
26
- clearInterval(intervalID);
27
- reject(
28
- new Error(
29
- "Accessibility Automation Scanner is not ready on the page."
30
- )
31
- );
32
- } else if (findAccessibilityAutomationElement()) {
33
- clearInterval(intervalID);
34
- resolve("Scanner set");
35
- } else {
36
- count += 1;
37
- }
25
+ if (count > retryCount) {
26
+ clearInterval(intervalID);
27
+ reject(
28
+ new Error(
29
+ "Accessibility Automation Scanner is not ready on the page."
30
+ )
31
+ );
32
+ } else if (findAccessibilityAutomationElement()) {
33
+ clearInterval(intervalID);
34
+ resolve("Scanner set");
35
+ } else {
36
+ count += 1;
37
+ }
38
38
  }, retryInterval);
39
- });
39
+ });
40
40
  }
41
41
 
42
42
  function startScan() {
43
- function onScanComplete() {
44
- win.removeEventListener("A11Y_SCAN_FINISHED", onScanComplete);
45
- resolve();
46
- }
43
+ function onScanComplete() {
44
+ win.removeEventListener("A11Y_SCAN_FINISHED", onScanComplete);
45
+ resolve();
46
+ }
47
47
 
48
- win.addEventListener("A11Y_SCAN_FINISHED", onScanComplete);
49
- const e = new CustomEvent("A11Y_SCAN", { detail: payloadToSend });
50
- win.dispatchEvent(e);
48
+ win.addEventListener("A11Y_SCAN_FINISHED", onScanComplete);
49
+ const e = new CustomEvent("A11Y_SCAN", { detail: payloadToSend });
50
+ win.dispatchEvent(e);
51
51
  }
52
52
 
53
53
  if (findAccessibilityAutomationElement()) {
54
- startScan();
54
+ startScan();
55
55
  } else {
56
- waitForScannerReadiness()
57
- .then(startScan)
58
- .catch(async (err) => {
59
- resolve("Scanner is not ready on the page after multiple retries. performscan");
60
- });
56
+ waitForScannerReadiness()
57
+ .then(startScan)
58
+ .catch(async (err) => {
59
+ resolve("Scanner is not ready on the page after multiple retries. performscan");
60
+ });
61
61
  }
62
- })
62
+ })
63
63
 
64
64
  const getAccessibilityResultsSummary = (win) =>
65
- new Promise((resolve) => {
65
+ new Promise((resolve) => {
66
66
  const isHttpOrHttps = /^(http|https):$/.test(window.location.protocol);
67
67
  if (!isHttpOrHttps) {
68
- resolve();
68
+ resolve();
69
69
  }
70
70
 
71
71
  function findAccessibilityAutomationElement() {
72
- return win.document.querySelector("#accessibility-automation-element");
72
+ return win.document.querySelector("#accessibility-automation-element");
73
73
  }
74
74
 
75
75
  function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
76
- return new Promise((resolve, reject) => {
77
- let count = 0;
78
- const intervalID = setInterval(() => {
79
- if (count > retryCount) {
80
- clearInterval(intervalID);
81
- reject(
82
- new Error(
83
- "Accessibility Automation Scanner is not ready on the page."
84
- )
85
- );
86
- } else if (findAccessibilityAutomationElement()) {
87
- clearInterval(intervalID);
88
- resolve("Scanner set");
89
- } else {
90
- count += 1;
91
- }
92
- }, retryInterval);
93
- });
76
+ return new Promise((resolve, reject) => {
77
+ let count = 0;
78
+ const intervalID = setInterval(() => {
79
+ if (count > retryCount) {
80
+ clearInterval(intervalID);
81
+ reject(
82
+ new Error(
83
+ "Accessibility Automation Scanner is not ready on the page."
84
+ )
85
+ );
86
+ } else if (findAccessibilityAutomationElement()) {
87
+ clearInterval(intervalID);
88
+ resolve("Scanner set");
89
+ } else {
90
+ count += 1;
91
+ }
92
+ }, retryInterval);
93
+ });
94
94
  }
95
95
 
96
96
  function getSummary() {
97
- function onReceiveSummary(event) {
98
-
99
- win.removeEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
100
- resolve(event.detail);
101
- }
97
+ function onReceiveSummary(event) {
98
+ win.removeEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
99
+ resolve(event.detail);
100
+ }
102
101
 
103
- win.addEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
104
- const e = new CustomEvent("A11Y_GET_RESULTS_SUMMARY");
105
- win.dispatchEvent(e);
102
+ win.addEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
103
+ const e = new CustomEvent("A11Y_GET_RESULTS_SUMMARY");
104
+ win.dispatchEvent(e);
106
105
  }
107
106
 
108
107
  if (findAccessibilityAutomationElement()) {
109
- getSummary();
108
+ getSummary();
110
109
  } else {
111
- waitForScannerReadiness()
112
- .then(getSummary)
113
- .catch((err) => {
114
- resolve();
115
- });
110
+ waitForScannerReadiness()
111
+ .then(getSummary)
112
+ .catch((err) => {
113
+ resolve();
114
+ });
116
115
  }
117
- })
116
+ })
118
117
 
119
118
  const getAccessibilityResults = (win) =>
120
- new Promise((resolve) => {
119
+ new Promise((resolve) => {
121
120
  const isHttpOrHttps = /^(http|https):$/.test(window.location.protocol);
122
121
  if (!isHttpOrHttps) {
123
- resolve();
122
+ resolve();
124
123
  }
125
124
 
126
125
  function findAccessibilityAutomationElement() {
127
- return win.document.querySelector("#accessibility-automation-element");
126
+ return win.document.querySelector("#accessibility-automation-element");
128
127
  }
129
128
 
130
129
  function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
131
- return new Promise((resolve, reject) => {
132
- let count = 0;
133
- const intervalID = setInterval(() => {
134
- if (count > retryCount) {
135
- clearInterval(intervalID);
136
- reject(
137
- new Error(
138
- "Accessibility Automation Scanner is not ready on the page."
139
- )
140
- );
141
- } else if (findAccessibilityAutomationElement()) {
142
- clearInterval(intervalID);
143
- resolve("Scanner set");
144
- } else {
145
- count += 1;
146
- }
147
- }, retryInterval);
148
- });
130
+ return new Promise((resolve, reject) => {
131
+ let count = 0;
132
+ const intervalID = setInterval(() => {
133
+ if (count > retryCount) {
134
+ clearInterval(intervalID);
135
+ reject(
136
+ new Error(
137
+ "Accessibility Automation Scanner is not ready on the page."
138
+ )
139
+ );
140
+ } else if (findAccessibilityAutomationElement()) {
141
+ clearInterval(intervalID);
142
+ resolve("Scanner set");
143
+ } else {
144
+ count += 1;
145
+ }
146
+ }, retryInterval);
147
+ });
149
148
  }
150
149
 
151
150
  function getResults() {
152
- function onReceivedResult(event) {
153
- win.removeEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
154
- resolve(event.detail);
155
- }
156
-
157
- win.addEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
158
- const e = new CustomEvent("A11Y_GET_RESULTS");
159
- win.dispatchEvent(e);
151
+ function onReceivedResult(event) {
152
+ win.removeEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
153
+ resolve(event.detail);
154
+ }
155
+
156
+ win.addEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
157
+ const e = new CustomEvent("A11Y_GET_RESULTS");
158
+ win.dispatchEvent(e);
160
159
  }
161
160
 
162
161
  if (findAccessibilityAutomationElement()) {
163
- getResults();
162
+ getResults();
164
163
  } else {
165
- waitForScannerReadiness()
166
- .then(getResults)
167
- .catch((err) => {
168
- resolve();
169
- });
164
+ waitForScannerReadiness()
165
+ .then(getResults)
166
+ .catch((err) => {
167
+ resolve();
168
+ });
170
169
  }
171
- });
170
+ });
172
171
 
173
172
  const saveTestResults = (win, payloadToSend) =>
174
- new Promise( (resolve, reject) => {
173
+ new Promise( (resolve, reject) => {
175
174
  try {
176
- const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
177
- if (!isHttpOrHttps) {
178
- resolve("Unable to save accessibility results, Invalid URL.");
179
- }
180
-
181
- function findAccessibilityAutomationElement() {
182
- return win.document.querySelector("#accessibility-automation-element");
183
- }
175
+ const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
176
+ if (!isHttpOrHttps) {
177
+ resolve("Unable to save accessibility results, Invalid URL.");
178
+ }
184
179
 
185
- function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
186
- return new Promise((resolve, reject) => {
187
- let count = 0;
188
- const intervalID = setInterval(async () => {
189
- if (count > retryCount) {
190
- clearInterval(intervalID);
191
- reject(
192
- new Error(
193
- "Accessibility Automation Scanner is not ready on the page."
194
- )
195
- );
196
- } else if (findAccessibilityAutomationElement()) {
197
- clearInterval(intervalID);
198
- resolve("Scanner set");
199
- } else {
200
- count += 1;
201
- }
202
- }, retryInterval);
203
- });
204
- }
180
+ function findAccessibilityAutomationElement() {
181
+ return win.document.querySelector("#accessibility-automation-element");
182
+ }
205
183
 
206
- function saveResults() {
207
- function onResultsSaved(event) {
208
- resolve();
184
+ function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
185
+ return new Promise((resolve, reject) => {
186
+ let count = 0;
187
+ const intervalID = setInterval(async () => {
188
+ if (count > retryCount) {
189
+ clearInterval(intervalID);
190
+ reject(
191
+ new Error(
192
+ "Accessibility Automation Scanner is not ready on the page."
193
+ )
194
+ );
195
+ } else if (findAccessibilityAutomationElement()) {
196
+ clearInterval(intervalID);
197
+ resolve("Scanner set");
198
+ } else {
199
+ count += 1;
200
+ }
201
+ }, retryInterval);
202
+ });
209
203
  }
210
- win.addEventListener("A11Y_RESULTS_SAVED", onResultsSaved);
211
- const e = new CustomEvent("A11Y_SAVE_RESULTS", {
212
- detail: payloadToSend,
213
- });
214
- win.dispatchEvent(e);
215
- }
216
204
 
217
- if (findAccessibilityAutomationElement()) {
218
- saveResults();
219
- } else {
220
- waitForScannerReadiness()
221
- .then(saveResults)
222
- .catch(async (err) => {
223
- resolve("Scanner is not ready on the page after multiple retries. after run");
224
- });
225
- }
205
+ function saveResults() {
206
+ function onResultsSaved(event) {
207
+ resolve();
208
+ }
209
+ win.addEventListener("A11Y_RESULTS_SAVED", onResultsSaved);
210
+ const e = new CustomEvent("A11Y_SAVE_RESULTS", {
211
+ detail: payloadToSend,
212
+ });
213
+ win.dispatchEvent(e);
214
+ }
226
215
 
216
+ if (findAccessibilityAutomationElement()) {
217
+ saveResults();
218
+ } else {
219
+ waitForScannerReadiness()
220
+ .then(saveResults)
221
+ .catch(async (err) => {
222
+ resolve("Scanner is not ready on the page after multiple retries. after run");
223
+ });
224
+ }
227
225
  } catch(er) {
228
- resolve()
226
+ resolve()
229
227
  }
230
228
 
231
- })
229
+ })
232
230
 
233
231
  const shouldScanForAccessibility = (attributes) => {
234
- if (Cypress.env("IS_ACCESSIBILITY_EXTENSION_LOADED") !== "true") return false;
232
+ if (Cypress.env("IS_ACCESSIBILITY_EXTENSION_LOADED") !== "true") return false;
235
233
 
236
- const extensionPath = Cypress.env("ACCESSIBILITY_EXTENSION_PATH");
237
- const isHeaded = Cypress.browser.isHeaded;
234
+ const extensionPath = Cypress.env("ACCESSIBILITY_EXTENSION_PATH");
235
+ const isHeaded = Cypress.browser.isHeaded;
238
236
 
239
- if (!isHeaded || (extensionPath === undefined)) return false;
237
+ if (!isHeaded || (extensionPath === undefined)) return false;
240
238
 
241
- let shouldScanTestForAccessibility = true;
239
+ let shouldScanTestForAccessibility = true;
242
240
 
243
- if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY") || Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
244
- try {
245
- let includeTagArray = [];
246
- let excludeTagArray = [];
247
- if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY")) {
248
- includeTagArray = Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
249
- }
250
- if (Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
251
- excludeTagArray = Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
252
- }
253
-
254
- const fullTestName = attributes.title;
255
- const excluded = excludeTagArray.some((exclude) => fullTestName.includes(exclude));
256
- const included = includeTagArray.length === 0 || includeTags.some((include) => fullTestName.includes(include));
257
- shouldScanTestForAccessibility = !excluded && included;
258
- } catch (error) {
259
- browserStackLog("Error while validating test case for accessibility before scanning. Error : ", error);
241
+ if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY") || Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
242
+ try {
243
+ let includeTagArray = [];
244
+ let excludeTagArray = [];
245
+ if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY")) {
246
+ includeTagArray = Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
247
+ }
248
+ if (Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
249
+ excludeTagArray = Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
250
+ }
251
+
252
+ const fullTestName = attributes.title;
253
+ const excluded = excludeTagArray.some((exclude) => fullTestName.includes(exclude));
254
+ const included = includeTagArray.length === 0 || includeTags.some((include) => fullTestName.includes(include));
255
+ shouldScanTestForAccessibility = !excluded && included;
256
+ } catch (error) {
257
+ browserStackLog("Error while validating test case for accessibility before scanning. Error : ", error);
258
+ }
260
259
  }
261
- }
262
260
 
263
- return shouldScanTestForAccessibility;
261
+ return shouldScanTestForAccessibility;
264
262
  }
265
263
 
266
264
  Cypress.on('command:start', async (command) => {
267
- if(!command || !command.attributes) return;
268
- if(command.attributes.name == 'window' || command.attributes.name == 'then' || command.attributes.name == 'wrap') {
269
- return;
270
- }
265
+ if(!command || !command.attributes) return;
266
+ if(command.attributes.name == 'window' || command.attributes.name == 'then' || command.attributes.name == 'wrap') {
267
+ return;
268
+ }
271
269
 
272
- if (!commandsToWrap.includes(command.attributes.name)) return;
270
+ if (!commandsToWrap.includes(command.attributes.name)) return;
273
271
 
274
- const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
272
+ const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
275
273
 
276
- let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
277
- if (!shouldScanTestForAccessibility) return;
274
+ let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
275
+ if (!shouldScanTestForAccessibility) return;
278
276
 
279
- cy.window().then((win) => {
280
- browserStackLog('Performing scan form command ' + command.attributes.name);
281
- cy.wrap(performScan(win, {method: command.attributes.name}), {timeout: 30000});
282
- })
277
+ cy.window().then((win) => {
278
+ browserStackLog('Performing scan form command ' + command.attributes.name);
279
+ cy.wrap(performScan(win, {method: command.attributes.name}), {timeout: 30000});
280
+ })
283
281
  })
284
282
 
285
283
  afterEach(() => {
286
- const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest;
287
- cy.window().then(async (win) => {
288
- let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
289
- if (!shouldScanTestForAccessibility) return cy.wrap({});
290
-
291
- cy.wrap(performScan(win), {timeout: 30000}).then(() => {
292
- try {
293
- let os_data;
294
- if (Cypress.env("OS")) {
295
- os_data = Cypress.env("OS");
296
- } else {
297
- os_data = Cypress.platform === 'linux' ? 'mac' : "win"
298
- }
299
- let filePath = '';
300
- if (attributes.invocationDetails !== undefined && attributes.invocationDetails.relativeFile !== undefined) {
301
- filePath = attributes.invocationDetails.relativeFile;
284
+ const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest;
285
+ cy.window().then(async (win) => {
286
+ let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
287
+ if (!shouldScanTestForAccessibility) return cy.wrap({});
288
+
289
+ cy.wrap(performScan(win), {timeout: 30000}).then(() => {
290
+ try {
291
+ let os_data;
292
+ if (Cypress.env("OS")) {
293
+ os_data = Cypress.env("OS");
294
+ } else {
295
+ os_data = Cypress.platform === 'linux' ? 'mac' : "win"
296
+ }
297
+ let filePath = '';
298
+ if (attributes.invocationDetails !== undefined && attributes.invocationDetails.relativeFile !== undefined) {
299
+ filePath = attributes.invocationDetails.relativeFile;
300
+ }
301
+ const payloadToSend = {
302
+ "saveResults": shouldScanTestForAccessibility,
303
+ "testDetails": {
304
+ "name": attributes.title,
305
+ "testRunId": '5058', // variable not consumed, shouldn't matter what we send
306
+ "filePath": filePath,
307
+ "scopeList": [
308
+ filePath,
309
+ attributes.title
310
+ ]
311
+ },
312
+ "platform": {
313
+ "os_name": os_data,
314
+ "os_version": Cypress.env("OS_VERSION"),
315
+ "browser_name": Cypress.browser.name,
316
+ "browser_version": Cypress.browser.version
317
+ }
318
+ };
319
+ browserStackLog(`Saving accessibility test results`);
320
+ cy.wrap(saveTestResults(win, payloadToSend), {timeout: 30000}).then(() => {
321
+ browserStackLog(`Saved accessibility test results`);
322
+ })
323
+
324
+ } catch (er) {
302
325
  }
303
- const payloadToSend = {
304
- "saveResults": shouldScanTestForAccessibility,
305
- "testDetails": {
306
- "name": attributes.title,
307
- "testRunId": '5058', // variable not consumed, shouldn't matter what we send
308
- "filePath": filePath,
309
- "scopeList": [
310
- filePath,
311
- attributes.title
312
- ]
313
- },
314
- "platform": {
315
- "os_name": os_data,
316
- "os_version": Cypress.env("OS_VERSION"),
317
- "browser_name": Cypress.browser.name,
318
- "browser_version": Cypress.browser.version
319
- }
320
- };
321
- browserStackLog(`Saving accessibility test results`);
322
- cy.wrap(saveTestResults(win, payloadToSend), {timeout: 30000}).then(() => {
323
- browserStackLog(`Saved accessibility test results`);
324
326
  })
325
-
326
- } catch (er) {
327
- }
328
- })
329
- });
327
+ });
330
328
  })
331
329
 
332
330
  Cypress.Commands.add('performScan', () => {
333
- try {
334
- const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
335
- const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
336
- if (!shouldScanTestForAccessibility) {
337
- browserStackLog(`Not a Accessibility Automation session, cannot perform scan.`);
338
- return cy.wrap({});
339
- }
340
- cy.window().then(async (win) => {
341
- browserStackLog(`Performing accessibility scan`);
342
- await performScan(win);
343
- });
344
- } catch {}
331
+ try {
332
+ const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
333
+ const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
334
+ if (!shouldScanTestForAccessibility) {
335
+ browserStackLog(`Not a Accessibility Automation session, cannot perform scan.`);
336
+ return cy.wrap({});
337
+ }
338
+ cy.window().then(async (win) => {
339
+ browserStackLog(`Performing accessibility scan`);
340
+ await performScan(win);
341
+ });
342
+ } catch {}
345
343
  })
346
344
 
347
345
  Cypress.Commands.add('getAccessibilityResultsSummary', () => {
348
- try {
349
- const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
350
- const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
351
- if (!shouldScanTestForAccessibility) {
352
- browserStackLog(`Not a Accessibility Automation session, cannot retrieve Accessibility results summary.`);
353
- return cy.wrap({});
354
- }
355
- cy.window().then(async (win) => {
356
- await performScan(win);
357
- browserStackLog('Getting accessibility results summary');
358
- return await getAccessibilityResultsSummary(win);
359
- });
360
- } catch {}
361
-
346
+ try {
347
+ const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
348
+ const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
349
+ if (!shouldScanTestForAccessibility) {
350
+ browserStackLog(`Not a Accessibility Automation session, cannot retrieve Accessibility results summary.`);
351
+ return cy.wrap({});
352
+ }
353
+ cy.window().then(async (win) => {
354
+ await performScan(win);
355
+ browserStackLog('Getting accessibility results summary');
356
+ return await getAccessibilityResultsSummary(win);
357
+ });
358
+ } catch {}
359
+
362
360
  });
363
361
 
364
362
  Cypress.Commands.add('getAccessibilityResults', () => {
365
- try {
366
- const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
367
- const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
368
- if (!shouldScanTestForAccessibility) {
369
- browserStackLog(`Not a Accessibility Automation session, cannot retrieve Accessibility results.`);
370
- return cy.wrap({});
371
- }
363
+ try {
364
+ const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
365
+ const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
366
+ if (!shouldScanTestForAccessibility) {
367
+ browserStackLog(`Not a Accessibility Automation session, cannot retrieve Accessibility results.`);
368
+ return cy.wrap({});
369
+ }
372
370
 
373
- /* browserstack_accessibility_automation_script */
371
+ /* browserstack_accessibility_automation_script */
374
372
 
375
- cy.window().then(async (win) => {
376
- await performScan(win);
377
- browserStackLog('Getting accessibility results');
378
- return await getAccessibilityResults(win);
379
- });
373
+ cy.window().then(async (win) => {
374
+ await performScan(win);
375
+ browserStackLog('Getting accessibility results');
376
+ return await getAccessibilityResults(win);
377
+ });
378
+
379
+ } catch {}
380
380
 
381
- } catch {}
382
-
383
381
  });