25 lines
988 B
JavaScript
25 lines
988 B
JavaScript
|
|
// Audit axe-core des pages clés servies sur localhost:4173
|
||
|
|
import { chromium } from '@playwright/test'
|
||
|
|
import { AxeBuilder } from '@axe-core/playwright'
|
||
|
|
|
||
|
|
const PAGES = ['/', '/outils', '/outils/signal', '/outils/tor', '/contribuer']
|
||
|
|
const browser = await chromium.launch()
|
||
|
|
const context = await browser.newContext()
|
||
|
|
const page = await context.newPage()
|
||
|
|
let total = 0
|
||
|
|
|
||
|
|
for (const path of PAGES) {
|
||
|
|
await page.goto(`http://localhost:4173${path}`, { waitUntil: 'networkidle' })
|
||
|
|
const results = await new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa', 'wcag22aa']).analyze()
|
||
|
|
total += results.violations.length
|
||
|
|
console.log(`\n═══ ${path} — ${results.violations.length} violation(s)`)
|
||
|
|
for (const v of results.violations) {
|
||
|
|
console.log(` [${v.impact}] ${v.id}: ${v.help}`)
|
||
|
|
for (const n of v.nodes.slice(0, 3)) console.log(` → ${n.target.join(' ')}`)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
await browser.close()
|
||
|
|
console.log(`\nTOTAL: ${total} violation(s)`)
|
||
|
|
process.exit(total > 0 ? 1 : 0)
|