mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-21 22:50:49 -06:00
example: a11y
Testing component accessibility
Usage
- Make sure the root project has been built .
# in the root of the project
npm install
npm run build
- Run
npm installin this folder to symlink the@cypress/reactdependency.
# in this folder
npm install
- Start Cypress
npm run cy:open
# or just run headless tests
npm test
Example
Testing components following the React accessibility guide using cypress-axe plugin.
See the spec file cypress/component/spec.js. For example, an <input> without a label is caught:
mount(<input type="text" value="John Smith" name="name" />)
cy.checkA11y('input', {
runOnly: {
type: 'tag',
values: ['wcag2a'],
},
})
You can click on the error to see more details in the DevTools console

