Software Testing & QA (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
Automated Accessibility (a11y) Testing with `axe-core` in CI/CD.
senior LevelMost AskedCode ExampleTestingCI/CD & DevOpsSystem Design
In Simple Words: Automating WCAG 2.1/2.2 AA compliance checks:
typescript
import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';
test('homepage accessibility audit', async ({ page }) => {
await page.goto('/');
const accessibilityScanResults = await new AxeBuilder({ page })
.withTags(['wcag2a', 'wcag2aa', 'wcag21aa'])
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
Automatically catches missing alt attributes, low color contrast ratios, missing form labels, and broken ARIA roles in every pull request.