Automated accessibility testing for websites using Playwright and axe-core. Generates combined HTML reports with violations grouped by rule and affected URLs.
- Automated accessibility scanning for all URLs found in a site's sitemap or CSV (temporary for AllerService).
- Supports environments: test, staging, production.
- Cookie consent auto-accept and login flow for protected pages (Prenumerera only).
- Grouped, detailed HTML report in
/artifacts. - Per-site and per-environment test scripts for granular control.
.
├── artifacts/
│ └── combined-accessibility-report.html # Output HTML report
├── node_modules/
├── src/
│ ├── types/
│ │ └── groupedViolation.d.ts
│ └── utils/
│ ├── createHtmlReport.ts
│ ├── getUrlsFromCsv.ts
│ ├── getUrlsFromSitemap.ts
│ └── groupNodes.ts
├── data/
│ └── allerservice-dk-urls.csv # Temporary CSV for AllerService URLs
├── tests/
│ ├── prenumerera-accessibility-scanner.test.ts
│ └── allerservice-accessibility-scanner.test.ts
├── .env
├── .env.production
├── .env.staging
├── .env.test
├── .gitignore
├── package.json
└── tsconfig.json
- Prenumerera: URLs are fetched from the sitemap of the site specified in the environment variable
PRENUMERERA_URL. - AllerService: URLs are currently fetched from a CSV file (
data/allerservice-dk-urls.csv) as a temporary solution. This will be updated to use the sitemap (ALLERSERVICE_URL) in the future.
- Environment is chosen by
NODE_ENV(test,staging,production). .env.*files are supported and gitignored.- Example
.env.production:NODE_ENV=test PRENUMERERA_URL=https://www.prenumerera.se/ PRENUMERERA_LOGIN_EMAIL=test@test.se PRENUMERERA_LOGIN_PASSWORD=test123 ALLERSERVICE_URL=https://www.allerservice.dk/ PLING_DK_URL=https://www.pling.dk/ PLING_SE_URL=https://www.pling.se/ - Axe rule tags are set in
.env:AXE_TAGS=wcag2a,wcag2aa,wcag21,wcag21a,wcag21aa,en301549
npm install- Edit
.env.*files for your environment and base URLs.
You can run all tests for an environment, or target a specific site and environment:
npm run test:test # Uses .env.test
npm run test:staging # Uses .env.staging
npm run test:prod # Uses .env.productionnpm run test:test:allerservice
npm run test:staging:allerservice
npm run test:prod:allerservice
npm run test:test:prenumerera
npm run test:staging:prenumerera
npm run test:prod:prenumereraYou can also use Playwright's CLI directly:
npx playwright test tests/prenumerera-accessibility-scanner.test.ts
npx playwright test tests/allerservice-accessibility-scanner.test.tsOpen artifacts/combined-accessibility-report.html or the generated report for your run in your browser.
- Prenumerera: Handles cookie consent and login before scanning. URLs are fetched from the sitemap.
- AllerService: No consent or login logic; scans all URLs from a CSV file (temporary). This will be updated to use the sitemap in the future.
- Add a new
.envvariable for the site's base URL. - Add a new test file in
tests/modeled after the existing ones. - Adjust login/consent logic as needed.
- Add a script to
package.jsonfor each environment if you want easy CLI access.
Summary:
This project scans all URLs found in a site's sitemap (or CSV, temporarily for AllerService) for accessibility issues using Playwright and axe-core, then generates a grouped HTML report. Each site can have its own test script and environment variable for configuration.