-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.cjs
More file actions
72 lines (63 loc) · 2.09 KB
/
check.cjs
File metadata and controls
72 lines (63 loc) · 2.09 KB
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
/* eslint-disable @typescript-eslint/no-require-imports */
const pa11y = require("pa11y");
const path = require("path");
const fs = require("fs");
const htmlReporter = require("pa11y-reporter-html");
const urls = [
"/",
"/instellingen",
"/berichtenbox",
"/bedrijfsprofiel",
"/contactmomenten",
];
const baseUrl = "http://localhost:3000"; //"https://moza.mijnoverheidzakelijk.nl"; // Pas aan naar localhost als je dat wilt
const outputDir = path.join(__dirname, "output");
// Create output directory if it doesn't exist
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir);
}
(async () => {
for (const pagepath of urls) {
const url = baseUrl + pagepath;
console.log(`\nRunning accessibility test for: ${url}`);
try {
const results = await pa11y(url, {
actions: [
"wait for element body to be visible",
"wait for element .button to be visible",
"click element .button",
"wait for element body to be visible",
"wait for element #username to be visible",
"set field #username to bedrijf",
"set field #password to password",
"click element #kc-login",
"screen capture output/login-screen.png",
"wait for element body to be visible",
],
screenCapture: path.join(
outputDir,
`screenshot-${pagepath.replace(/\//g, "")}.png`,
),
standard: "WCAG2AA",
timeout: 3000,
viewport: {
height: 1080,
width: 1920,
},
reporter: "html", // Use the built-in html reporter
});
const htmlReport = await htmlReporter.results(results);
const reportFilename = path.join(
outputDir,
`report-${pagepath.replace(/\//g, "")}.html`,
);
fs.writeFileSync(reportFilename, htmlReport);
console.log("Accessibility issues found:\n");
results.issues.forEach((issue) => {
console.log(`[${issue.type}] ${issue.message} (on ${issue.selector})`);
});
} catch (error) {
console.error(`Pa11y failed to run for ${url}:\n`, error);
}
}
})();