diff --git a/packages/volto/cypress/support/commands.js b/packages/volto/cypress/support/commands.js index f8ba71f310..5ea83b651e 100644 --- a/packages/volto/cypress/support/commands.js +++ b/packages/volto/cypress/support/commands.js @@ -967,3 +967,25 @@ Cypress.Commands.add('queryCounter', (path, steps, number = 1) => { cy.get('@counterName').its('callCount').should('equal', number); }); + +// Print cypress-axe violations to the terminal +function printAccessibilityViolations(violations) { + cy.task( + 'table', + violations.map(({ id, impact, description, nodes }) => ({ + impact, + description: `${description} (${id})`, + nodes: nodes.length, + })), + ); +} + +Cypress.Commands.add( + 'checkAccessibility', + (subject, { skipFailures = false } = {}) => { + cy.checkA11y(subject, null, printAccessibilityViolations, skipFailures); + }, + { + prevSubject: 'optional', + }, +); diff --git a/packages/volto/news/6606.feature b/packages/volto/news/6606.feature new file mode 100644 index 0000000000..70506d90d7 --- /dev/null +++ b/packages/volto/news/6606.feature @@ -0,0 +1 @@ +feat(cypress):Add custom check Accessibility command @Tishasoumya-02 \ No newline at end of file