Skip to content

Commit fe6ae73

Browse files
committed
Try adding axe-core.
1 parent 4676feb commit fe6ae73

3 files changed

Lines changed: 77 additions & 6 deletions

File tree

‎package-lock.json‎

Lines changed: 38 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"last 2 Opera versions"
2929
],
3030
"devDependencies": {
31+
"@axe-core/playwright": "4.13.0",
3132
"@lodder/grunt-postcss": "^3.1.1",
3233
"@playwright/test": "1.61.1",
3334
"@pmmmwh/react-refresh-webpack-plugin": "0.6.2",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { test, expect } from '@wordpress/e2e-test-utils-playwright';
2+
const AxeBuilder = require( '@axe-core/playwright' ).default;
3+
4+
test.describe( 'PHP Page Accessibility Tests', () => {
5+
test( 'should not have any automatically detectable accessibility violations', async ( { admin, page, requestUtils } ) => {
6+
7+
// await requestUtils.login();
8+
// await page.goto( 'http://localhost:8889/wp-admin/edit.php');
9+
await admin.visitAdminPage( '/edit.php' );
10+
11+
// 2. Run the axe scan on the rendered page
12+
const scanResults = await new AxeBuilder({ page }).analyze();
13+
14+
// 3. Format and print violations individually if any are found
15+
if (scanResults.violations.length > 0) {
16+
console.log(`\n❌ Found ${scanResults.violations.length} accessibility violation(s):\n`);
17+
18+
scanResults.violations.forEach((violation, index) => {
19+
console.log(`--- Violation #${index + 1} ---`);
20+
console.log(`Rule ID: ${violation.id}`);
21+
console.log(`Impact: ${violation.impact.toUpperCase()}`);
22+
console.log(`Failure: ${violation.description}`);
23+
console.log(`Help Link: ${violation.helpUrl}`);
24+
25+
// List every specific HTML element failing this rule
26+
console.log('Failing Elements:');
27+
violation.nodes.forEach((node) => {
28+
console.log(` - Target Selector: ${node.target.join(', ')}`);
29+
console.log(` HTML Snippet: ${node.html}`);
30+
});
31+
console.log('\n');
32+
});
33+
}
34+
35+
// 3. Assert that the violations list is empty
36+
expect(scanResults.violations).toEqual([]);
37+
});
38+
});

0 commit comments

Comments
 (0)