Intro
The @userway/a11y-cypress
is an NPM package designed to help you perform accessibility testing on your web pages. With it you can easily run static page analysis on a webpage and get a detailed report of accessibility violations based on WCAG guidelines and ACT rules. The library extends Cypress's cy
commands, making it easy to integrate into your testing workflow by using a few lines of code.
// cypress/e2e/my-test.js
it('basic example', () => {
cy.visit('some example website')
cy.userwayAnalysis()
})
Prerequisites
Cypress version 10.0.0
or higher
Distribution
UserWay App Cypress is distributed as a zip-packaged NPM module and should be installed as an NPM dependency.
Installation
First, extract the provided userway-cypress-app.zip
inside of a separate
directory, like src/packages
:
src
└── packages
├── userway-app-cypress.zip
└── userway-app-cypress
Install userway-app-cypress
with npm install
:
npm install src/packages/userway-cypress-app
This adds @userway/a11y-cypress
to the dependencies in package.json
.
Setup
UserWay App Cypress
extends Cypress's cy
commands.
Add this import to your Cypress's support file (usually cypress/support/e2e.js
):
import '@userway/a11y-cypress'
Now you have access to cy.userwayAnalysis
and cy.userwaySaveReport
in your Cypress's tests.
Types
If you are using TypeScript, add @userway/a11y-cypress
to types
section in your tsconfig.json:
{
"compilerOptions": {
"types": ["cypress", "@userway/a11y-cypress"]
}
}
If you are not using TypeScript, you can still have autocompletion available by adding type references to your tests:
/// <reference types="cypress" />
/// <reference types="@userway/a11y-cypress" />
// ↑ Add this at the top of your test