This repository includes automated accessibility testing for every pull request and merge to ensure your application meets accessibility standards.
-
GitHub Actions Workflow (
.github/workflows/accessibility.yml)- Runs on every pull request and push to main/master/develop branches
- Performs automated accessibility checks
- Uses Lighthouse for comprehensive accessibility auditing
- Checks for common accessibility issues in HTML
-
Accessibility Test Suite (
my-app/__tests__/accessibility.test.tsx)- Tests for proper image alt text
- Validates form labels and accessibility
- Checks heading structure
- Ensures button and link accessibility
- Uses regex-based HTML parsing for reliability
-
Configuration Files
.pa11yci.json- Pa11y accessibility testing configurationlighthouserc.json- Lighthouse CI configuration
The accessibility testing workflow:
- Builds your application to ensure all components are compiled
- Runs basic accessibility tests using the test suite
- Scans built HTML files for common accessibility issues:
- Images without alt text
- Form inputs without proper labels
- Improper heading structure
- Runs Lighthouse accessibility audit for comprehensive testing
- Uploads test results as artifacts for review
The tests check for compliance with:
- WCAG 2.1 AA standards
- Section 508 requirements
- Common accessibility best practices
To run accessibility tests locally:
cd my-app
npm testTo run only accessibility tests:
cd my-app
npm run test:accessibility- ✅ All images have alt text
- ✅ Decorative images have empty alt attributes
- ❌ Images without alt text are flagged
- ✅ Form inputs have associated labels
- ✅ Inputs with IDs have corresponding label elements
- ✅ Inputs use aria-label or aria-labelledby when appropriate
- ❌ Unlabeled inputs are flagged
- ✅ Headings follow proper hierarchy (h1 → h2 → h3)
- ❌ Skipped heading levels are flagged
- ✅ Buttons have accessible names (text, aria-label, or title)
- ✅ Links have descriptive text or aria-labels
- ❌ Elements without accessible names are flagged
- Comprehensive accessibility scoring
- Detailed violation reports
- Performance and best practices checks
You can customize the accessibility tests by:
- Modifying test thresholds in
lighthouserc.json - Adding custom test cases in
accessibility.test.tsx - Updating pa11y configuration in
.pa11yci.json - Adjusting GitHub Actions workflow in
.github/workflows/accessibility.yml
After a pull request or push:
- Go to the Actions tab in your GitHub repository
- Click on the Accessibility Testing workflow run
- Download the accessibility-test-results artifact
- Review the Lighthouse accessibility report
<!-- ❌ Bad -->
<img src="logo.png" />
<!-- ✅ Good -->
<img src="logo.png" alt="Company Logo" />
<img src="decorative.png" alt="" /><!-- ❌ Bad -->
<input type="text" id="name" />
<!-- ✅ Good -->
<label for="name">Name:</label>
<input type="text" id="name" /><!-- ❌ Bad -->
<h1>Main Title</h1>
<h3>Subsection</h3>
<!-- ✅ Good -->
<h1>Main Title</h1>
<h2>Section</h2>
<h3>Subsection</h3>If you encounter issues with the accessibility testing:
- Check the GitHub Actions logs for detailed error messages
- Review the Lighthouse accessibility report for specific violations
- Use browser developer tools to test accessibility manually
- Consider using screen readers for manual testing
When contributing to this repository:
- Ensure your changes pass all accessibility tests
- Add new test cases for any accessibility features you implement
- Update documentation if you modify the testing configuration