Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 0faa32e

Browse files
committed
fix tests not running
1 parent bf7bd3f commit 0faa32e

File tree

3 files changed

+71
-6
lines changed

3 files changed

+71
-6
lines changed

cypress.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ export default defineConfig({
44
e2e: {
55
baseUrl: 'http://localhost:3000',
66
setupNodeEvents(on, config) {
7-
// require("cypress-fail-fast/plugin")(on, config);
8-
return config
7+
on('task', {
8+
log(message) {
9+
console.log(message)
10+
11+
return null
12+
},
13+
table(message) {
14+
console.table(message)
15+
16+
return null
17+
},
18+
})
919
},
1020
},
1121
})

cypress/e2e/a11y.cy.ts

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,72 @@ import * as pages from '../fixtures/pages.json'
22

33
describe('a11y accessiblity test suite', () => {
44
pages.forEach((page) => {
5-
it(`Should test page ${page} for a11y violations`, () => {
5+
it(`Should test page ${page} for a11y violations on desktop`, () => {
66
cy.viewport('macbook-16')
77
cy.visit(page)
88
cy.injectAxe()
9-
cy.wait(150)
9+
cy.wait(1500)
1010
cy.checkA11y(
1111
undefined,
1212
{
1313
includedImpacts: ['critical'],
1414
},
15-
);
15+
(violations) => {
16+
cy.task(
17+
'log',
18+
`${violations.length} accessibility violation${
19+
violations.length === 1 ? '' : 's'
20+
} ${violations.length === 1 ? 'was' : 'were'} detected`,
21+
)
22+
// pluck specific keys to keep the table readable
23+
const violationData = violations.map(
24+
({ id, impact, description, nodes }) => ({
25+
id,
26+
impact,
27+
description,
28+
nodes: nodes.length,
29+
}),
30+
)
31+
32+
cy.task('table', violationData)
33+
34+
// console.error(JSON.stringify(violations));
35+
},
36+
)
37+
})
38+
39+
it(`Should test page ${page} for a11y violations on mobile`, () => {
40+
cy.viewport('iphone-x')
41+
cy.visit(page)
42+
cy.injectAxe()
43+
cy.wait(1500)
44+
cy.checkA11y(
45+
undefined,
46+
{
47+
includedImpacts: ['critical'],
48+
},
49+
(violations) => {
50+
cy.task(
51+
'log',
52+
`${violations.length} accessibility violation${
53+
violations.length === 1 ? '' : 's'
54+
} ${violations.length === 1 ? 'was' : 'were'} detected`,
55+
)
56+
// pluck specific keys to keep the table readable
57+
const violationData = violations.map(
58+
({ id, impact, description, nodes }) => ({
59+
id,
60+
impact,
61+
description,
62+
nodes: nodes.length,
63+
}),
64+
)
65+
66+
cy.task('table', violationData)
67+
68+
// console.error(JSON.stringify(violations));
69+
},
70+
)
1671
})
1772
})
1873
})

scripts/build-pages-fixture.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async function run() {
88
try {
99
const paths = allDocs
1010
.map((doc) => {
11-
return doc.slug ? `/${doc.slug}` : '/'
11+
return doc.slug === '/' ? '/docs' : `/docs/${doc.slug}`
1212
})
1313
.sort((a, b) => a.localeCompare(b))
1414

0 commit comments

Comments
 (0)