2
2
const LambdatestLog = ( message ) => {
3
3
if ( ! Cypress . env ( 'LAMBDATEST_LOGS' ) ) return ;
4
4
cy . task ( 'lambdatest_log' , message ) ;
5
- }
5
+ }
6
6
7
7
const commandsToWrap = [ 'visit' , 'click' , 'type' , 'request' , 'dblclick' , 'rightclick' , 'clear' , 'check' , 'uncheck' , 'select' , 'trigger' , 'selectFile' , 'scrollIntoView' , 'scroll' , 'scrollTo' , 'blur' , 'focus' , 'go' , 'reload' , 'submit' , 'viewport' , 'origin' ] ;
8
8
@@ -133,30 +133,31 @@ function processAccessibilityReport(win){
133
133
} ) ;
134
134
}
135
135
136
- // Cypress.on('window:load ', 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
- // }
148
- //
149
- //
150
- // console.log('log', "debugging scan form command " + command.attributes.name);
151
- //
152
- // cy.window().then((win) => {
153
- // processAccessibilityReport(win);
154
- // });
155
- // })
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
+ }
148
+
149
+
150
+ console . log ( 'log' , "debugging scan form command " + command . attributes . name ) ;
151
+
152
+ cy . window ( ) . then ( ( win ) => {
153
+ processAccessibilityReport ( win ) ;
154
+ } ) ;
155
+ } )
156
156
157
157
// Ensure scan runs AFTER visit completes
158
158
Cypress . Commands . overwrite ( 'visit' , ( originalFn , url , options ) => {
159
- return originalFn ( url , options ) . then ( ( ) => {
159
+ function getReportAfterVisiting ( ) {
160
+ originalFn ( url , options )
160
161
let isAccessibilityLoaded = Cypress . env ( "ACCESSIBILITY" ) || false ;
161
162
if ( ! isAccessibilityLoaded ) {
162
163
console . log ( 'log' , "Accessibility not enabled." ) ;
@@ -167,7 +168,9 @@ Cypress.Commands.overwrite('visit', (originalFn, url, options) => {
167
168
console . log ( 'log' , "Running accessibility scan after visit: " + url ) ;
168
169
processAccessibilityReport ( win ) ;
169
170
} ) ;
170
- } ) ;
171
+ }
172
+
173
+ return getReportAfterVisiting ( ) ;
171
174
} ) ;
172
175
173
176
@@ -178,15 +181,15 @@ return;
178
181
179
182
180
183
afterEach ( ( ) => {
181
- console . log ( "after each hook" )
182
- let isAccessibilityLoaded = Cypress . env ( "ACCESSIBILITY" ) || false ;
183
- if ( ! isAccessibilityLoaded ) {
184
- console . log ( 'log' , "accessibility not enabled " + isAccessibilityLoaded ) ;
185
- return ;
186
- }
187
- cy . window ( ) . then ( ( win ) => {
188
- processAccessibilityReport ( win ) ;
189
- } )
184
+ console . log ( "after each hook" )
185
+ let isAccessibilityLoaded = Cypress . env ( "ACCESSIBILITY" ) || false ;
186
+ if ( ! isAccessibilityLoaded ) {
187
+ console . log ( 'log' , "accessibility not enabled " + isAccessibilityLoaded ) ;
188
+ return ;
189
+ }
190
+ cy . window ( ) . then ( ( win ) => {
191
+ processAccessibilityReport ( win ) ;
192
+ } )
190
193
191
194
192
195
} )
0 commit comments