Intro
The @level-ci/a11y-playwright
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.
// playwright/e2e/my-test.spec.js
test('example test', async ({ page }) => {
await page.goto('http://localhost:5000')
await levelAnalyze(page)
})
Prerequisites
Playwright version 1.16.0
or higher
Distribution
Level CI App Playwright is distributed as a zip-packaged NPM module and should be installed as an NPM dependency.
Installation
First, extract the provided level-ci-app-playwright.zip
inside of a separate
directory, like src/packages
:
src
└── packages
├── level-ci-app-playwright.zip
└── level-ci-app-playwright
Install level-ci-app-playwright
with npm install
:
npm install src/packages/level-ci-app-playwright
This adds @level-ci/a11y-playwright
to the dependencies in package.json
.
Setup
Level CI App Playwright
external package and needs to be imported in playwright test.
Import @level-ci/a11y-playwright
to your Playwright’s test file and call levelAnalyze
function:
const { levelAnalyze } = require('@level-ci/a11y-playwright')
test('example test', async ({ page }) => {
await page.goto('http://localhost:5000')
await levelAnalyze(page)
})
Types
If you are using TypeScript, add @level-ci/a11y-playwright
to types
section in your tsconfig.json:
{
"compilerOptions": {
"types": ["playwright", "@level-ci/a11y-playwright"]
}
}
If you are not using TypeScript, you can still have autocompletion available by adding type references to your tests:
/// <reference types="playwright" />
/// <reference types="@level-ci/a11y-playwright" />
// ↑ Add this at the top of your test