-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (37 loc) · 995 Bytes
/
index.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
import { parseArgs } from "node:util";
import { runAccessSniff } from "./lib/access-sniff.js";
import { runAxe } from "./lib/axe.js";
// Detect `--access-sniff` and `--axe` flags
const args = parseArgs({
options: {
"access-sniff": {
type: "boolean",
},
axe: {
type: "boolean",
},
},
args: process.argv.slice(2),
});
// Validate flags
if (!args.values["access-sniff"] && !args.values["axe"]) {
console.error(
"Please pass `--access-sniff` or `--axe` or both. Example: `npm run test -- --axe`"
);
process.exit(1);
}
// Run AccessSniff
if (args.values["access-sniff"]) {
await runAccessSniff({
// https://github.com/yargalot/AccessSniff#options
accessibilityLevel: "WCAG2AA",
ignore: ["WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.BgImage"],
});
}
// Run Axe
if (args.values["axe"]) {
await runAxe({
// https://github.com/dequelabs/axe-core/blob/master/doc/API.md#axe-core-tags
checks: { region: { enabled: false } },
});
}