@@ -133,26 +133,23 @@ function processAccessibilityReport(win){
133
133
} ) ;
134
134
}
135
135
136
- Cypress . on ( 'command:start' , async ( command ) => {
137
- if ( ! command || ! command . attributes ) return ;
138
- if ( command . attributes . name == 'window' || command . attributes . name == 'then' || command . attributes . name == 'wrap' || command . attributes . name == 'wait' ) {
139
- return ;
140
- }
141
-
142
- if ( ! commandsToWrap . includes ( command . attributes . name ) ) return ;
143
- let isAccessibilityLoaded = Cypress . env ( "ACCESSIBILITY" ) || false ;
144
- if ( ! isAccessibilityLoaded ) {
145
- console . log ( 'log' , "accessibility not enabled " + isAccessibilityLoaded ) ;
146
- return ;
147
- }
136
+ commandsToWrap . forEach ( ( command ) => {
137
+ Cypress . Commands . overwrite ( command , ( originalFn , ...args ) => {
138
+ let isAccessibilityLoaded = Cypress . env ( "ACCESSIBILITY" ) || false ;
139
+ if ( ! isAccessibilityLoaded ) {
140
+ console . log ( 'log' , "accessibility not enabled " + isAccessibilityLoaded ) ;
141
+ return originalFn ( ...args ) ;
142
+ }
148
143
144
+ console . log ( 'log' , "debugging scan for command " + command ) ;
145
+ cy . window ( ) . then ( ( win ) => {
146
+ processAccessibilityReport ( win ) ;
147
+ } ) ;
149
148
150
- console . log ( 'log' , "debugging scan form command " + command . attributes . name ) ;
149
+ return originalFn ( ...args ) ;
150
+ } ) ;
151
+ } ) ;
151
152
152
- cy . window ( ) . then ( ( win ) => {
153
- processAccessibilityReport ( win ) ;
154
- } )
155
- } )
156
153
157
154
158
155
Cypress . on ( 'command:end' , ( command ) => {
0 commit comments