-
Notifications
You must be signed in to change notification settings - Fork 227
/
accessiblity_audit.test.js
77 lines (64 loc) · 2.36 KB
/
accessiblity_audit.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const { AxePuppeteer } = require('axe-puppeteer')
const { setupPage } = require('../lib/jest-utilities.js')
const configPaths = require('../lib/paths.js')
const PORT = configPaths.testPort
let page
const baseUrl = 'http://localhost:' + PORT
async function audit (page) {
const axe = new AxePuppeteer(page)
.include('body')
// axe reports there is "no label associated with the text field", when there is one.
.exclude('#app-site-search__input')
// axe reports that the phase banner is not inside a landmark, which is intentional.
.exclude('.app-phase-banner')
// axe reports that the skip link is not inside a landmark, which is intentional.
// https://design-system.service.gov.uk/components/skip-link/#when-to-use-this-component
.exclude('.govuk-skip-link')
// axe reports that the back to top button is not inside a landmark, which is intentional.
.exclude('.app-back-to-top')
const results = await axe.analyze()
return results.violations
}
beforeAll(async () => {
page = await setupPage()
})
afterAll(async () => {
await page.close()
})
describe('Accessibility Audit', () => {
describe('Home page - layout.njk', () => {
it('validates', async () => {
await page.goto(baseUrl + '/', { waitUntil: 'load' })
const violations = await audit(page)
expect(violations).toEqual([])
})
})
describe('Component page - layout-pane.njk', () => {
it('validates', async () => {
await page.goto(baseUrl + '/components/radios/', { waitUntil: 'load' })
const violations = await audit(page)
expect(violations).toEqual([])
})
})
describe('Patterns page - layout-pane.njk', () => {
it('validates', async () => {
await page.goto(baseUrl + '/patterns/gender-or-sex/', { waitUntil: 'load' })
const violations = await audit(page)
expect(violations).toEqual([])
})
})
describe('Get in touch page - layout-single-page.njk', () => {
it('validates', async () => {
await page.goto(baseUrl + '/get-in-touch/', { waitUntil: 'load' })
const violations = await audit(page)
expect(violations).toEqual([])
})
})
describe('Site Map page - layout-sitemap.njk', () => {
it('validates', async () => {
await page.goto(baseUrl + '/sitemap/', { waitUntil: 'load' })
const violations = await audit(page)
expect(violations).toEqual([])
})
})
})