🕵️ Code PushUp plugin for automated accessibility testing with Axe. 🌐
The plugin runs accessibility audits on web pages using axe-core via Playwright. It identifies WCAG violations and best practice recommendations, providing 100+ accessibility metrics with detailed guidance for fixing problems.
Why accessibility testing matters: The European Accessibility Act (EAA) requires digital products and services in the EU to meet accessibility standards closely aligned with the Web Content Accessibility Guidelines (WCAG). This plugin provides comprehensive automated testing to help meet compliance requirements and build inclusive experiences.
-
If you haven't already, install @code-pushup/cli and create a configuration file.
-
Install as a dev dependency with your package manager:
npm install --save-dev @code-pushup/axe-plugin
yarn add --dev @code-pushup/axe-plugin
pnpm add --save-dev @code-pushup/axe-plugin
-
Add this plugin to the
pluginsarray in your Code PushUp CLI config file (e.g.code-pushup.config.ts).Pass in the URL you want to test:
import axePlugin from '@code-pushup/axe-plugin'; export default { // ... plugins: [ // ... axePlugin('https://example.com'), ], };
By default, the plugin runs WCAG 2.1 Level AA audits. You can customize this using presets.
-
Run the CLI with
npx code-pushup collectand view or upload the report (refer to CLI docs).Note: The plugin uses Playwright to run tests in Chromium. The browser will be installed automatically if not already present.
axePlugin(urls: PluginUrls, options?: AxePluginOptions)Parameters:
urls- URL(s) to test. See Multiple URLs section below, orPluginUrlsreferenceoptions- Optional configuration object
Options:
| Property | Type | Default | Description |
|---|---|---|---|
preset |
AxePreset |
'wcag21aa' |
Accessibility ruleset preset |
scoreTargets |
object |
undefined |
Pass/fail thresholds for audits or groups |
See Presets for the list of available presets and Preset details for what each preset includes.
The plugin supports testing single or multiple URLs:
// Single URL (string)
axePlugin('https://example.com');
// Multiple URLs (array)
axePlugin(['https://example.com', 'https://example.com/about']);
// Weighted URLs (record)
axePlugin({
'https://example.com': 3, // homepage has 3x weight
'https://example.com/about': 1, // about page has 1x weight
});URLs with higher weights contribute more to overall scores. For example, a URL with weight 3 has three times the influence of a URL with weight 1.
Choose which accessibility ruleset to test against using the preset option:
axePlugin('https://example.com', {
preset: 'wcag22aa',
});Available presets:
| Preset | Description | Use case |
|---|---|---|
wcag21aa |
WCAG 2.1 Level A and AA (default) | Standard web accessibility compliance |
wcag22aa |
WCAG 2.2 Level A and AA | Latest WCAG standard |
best-practice |
Best practices (non-WCAG recommendations) | Deque's additional recommendations |
all |
All available rules | Comprehensive testing |
wcag21aa (default)
- Tests compliance with WCAG 2.1 Level A and Level AA
- Required for European Accessibility Act (EAA) compliance
- Covers fundamentals: keyboard navigation, color contrast, form labels, alt text, etc.
wcag22aa
- Tests compliance with WCAG 2.2 Level A and Level AA
- Includes all WCAG 2.1 rules plus new success criteria
- Future-proof for upcoming regulations
best-practice
- Non-WCAG recommendations from Deque Systems
- Goes beyond legal requirements
- Helps create more inclusive experiences
all
- Runs every rule available in axe-core
- Includes WCAG 2.0, 2.1, 2.2, experimental rules, and best practices
- Most comprehensive testing
Note: Different pages may trigger different sets of rules depending on their content. For example, a page without video won't run video-related audits.
The plugin organizes audits into category groups based on axe-core's accessibility categories:
aria- ARIAcolor- Color & Contrastforms- Formskeyboard- Keyboardlanguage- Languagename-role-value- Names & Labelsparsing- Parsingsemantics- Semanticssensory-and-visual-cues- Visual Cuesstructure- Structuretables- Tablestext-alternatives- Text Alternativestime-and-media- Media
Use npx code-pushup print-config --onlyPlugins=axe to list all audits and groups for your configuration.
- Axe-core rules - Complete list of accessibility rules
- Deque University - Detailed explanations and remediation guidance
- WCAG Guidelines - Web Content Accessibility Guidelines