@@ -18,7 +18,7 @@ new Promise(async (resolve, reject) => {
18
18
return win . document . querySelector ( "#accessibility-automation-element" ) ;
19
19
}
20
20
21
- function waitForScannerReadiness ( retryCount = 30 , retryInterval = 100 ) {
21
+ function waitForScannerReadiness ( retryCount = 100 , retryInterval = 100 ) {
22
22
return new Promise ( async ( resolve , reject ) => {
23
23
let count = 0 ;
24
24
const intervalID = setInterval ( async ( ) => {
@@ -261,24 +261,16 @@ const shouldScanForAccessibility = (attributes) => {
261
261
return shouldScanTestForAccessibility ;
262
262
}
263
263
264
- Cypress . on ( 'command:start' , async ( command ) => {
265
- if ( ! command || ! command . attributes ) return ;
266
- if ( command . attributes . name == 'window' || command . attributes . name == 'then' || command . attributes . name == 'wrap' ) {
267
- return ;
268
- }
269
-
270
- if ( ! commandsToWrap . includes ( command . attributes . name ) ) return ;
271
-
272
- const attributes = Cypress . mocha . getRunner ( ) . suite . ctx . currentTest || Cypress . mocha . getRunner ( ) . suite . ctx . _runnable ;
273
-
274
- let shouldScanTestForAccessibility = shouldScanForAccessibility ( attributes ) ;
275
- if ( ! shouldScanTestForAccessibility ) return ;
264
+ const commandToOverwrite = [ 'visit' , 'click' , 'type' , 'request' , 'dblclick' , 'rightclick' , 'clear' , 'check' , 'uncheck' , 'select' , 'trigger' , 'selectFile' , 'scrollIntoView' , 'scrollTo' , 'blur' , 'focus' , 'go' , 'reload' , 'submit' , 'viewport' , 'origin' ] ;
265
+ commandToOverwrite . forEach ( ( command ) => {
266
+ Cypress . Commands . overwrite ( command , ( originalFn , url , options ) => {
267
+ const attributes = Cypress . mocha . getRunner ( ) . suite . ctx . currentTest || Cypress . mocha . getRunner ( ) . suite . ctx . _runnable ;
268
+ let shouldScanTestForAccessibility = shouldScanForAccessibility ( attributes ) ;
269
+ if ( ! shouldScanTestForAccessibility ) return ;
270
+ cy . wrap ( null ) . performScan ( ) . then ( ( ) => originalFn ( url , options ) ) ;
271
+ } ) ;
272
+ } ) ;
276
273
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
- } )
281
- } )
282
274
283
275
afterEach ( ( ) => {
284
276
const attributes = Cypress . mocha . getRunner ( ) . suite . ctx . currentTest ;
@@ -337,7 +329,7 @@ Cypress.Commands.add('performScan', () => {
337
329
}
338
330
cy . window ( ) . then ( async ( win ) => {
339
331
browserStackLog ( `Performing accessibility scan` ) ;
340
- await performScan ( win ) ;
332
+ cy . wrap ( performScan ( win ) , { timeout : 40000 } ) ;
341
333
} ) ;
342
334
} catch { }
343
335
} )
0 commit comments