@@ -18,7 +18,7 @@ new Promise(async (resolve, reject) => {
1818 return win . document . querySelector ( "#accessibility-automation-element" ) ;
1919 }
2020
21- function waitForScannerReadiness ( retryCount = 30 , retryInterval = 100 ) {
21+ function waitForScannerReadiness ( retryCount = 100 , retryInterval = 100 ) {
2222 return new Promise ( async ( resolve , reject ) => {
2323 let count = 0 ;
2424 const intervalID = setInterval ( async ( ) => {
@@ -261,24 +261,16 @@ const shouldScanForAccessibility = (attributes) => {
261261 return shouldScanTestForAccessibility ;
262262}
263263
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+ } ) ;
276273
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- } )
282274
283275afterEach ( ( ) => {
284276 const attributes = Cypress . mocha . getRunner ( ) . suite . ctx . currentTest ;
@@ -337,7 +329,7 @@ Cypress.Commands.add('performScan', () => {
337329 }
338330 cy . window ( ) . then ( async ( win ) => {
339331 browserStackLog ( `Performing accessibility scan` ) ;
340- await performScan ( win ) ;
332+ cy . wrap ( performScan ( win ) , { timeout : 40000 } ) ;
341333 } ) ;
342334 } catch { }
343335} )
0 commit comments