Skip to content

Commit 71e51b2

Browse files
authored
Merge pull request #351 from abhishek-lambda/AT-281
CLI-Custom-changes
2 parents 2a8d643 + 179e62d commit 71e51b2

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

accessibility/scanner/index.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,26 +133,23 @@ function processAccessibilityReport(win){
133133
});
134134
}
135135

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+
}
148143

144+
console.log('log', "debugging scan for command " + command);
145+
cy.window().then((win) => {
146+
processAccessibilityReport(win);
147+
});
149148

150-
console.log('log', "debugging scan form command " + command.attributes.name);
149+
return originalFn(...args);
150+
});
151+
});
151152

152-
cy.window().then((win) => {
153-
processAccessibilityReport(win);
154-
})
155-
})
156153

157154

158155
Cypress.on('command:end', (command) => {

0 commit comments

Comments
 (0)