-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
basic-axe-playwright.spec.ts
58 lines (52 loc) · 1.53 KB
/
basic-axe-playwright.spec.ts
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
import assert from "assert";
import { writeFileSync } from "fs";
import { Standard, kayle } from "kayle";
import { drakeMock } from "./mocks/html-mock";
import { performance } from "perf_hooks";
import { test } from "@playwright/test";
test("fast_axecore audit drakeMock", async ({ page, browser }, testInfo) => {
if (process.env.LOG_ENABLED) {
page.on("console", (msg) => console.log("PAGE LOG:", msg.text()));
}
const startTime = performance.now();
const results = await kayle({
page,
browser,
runners: ["axe"],
includeWarnings: true,
standard: Standard.WCAG2AA,
origin: "https://www.drake.com",
html: drakeMock,
waitUntil: "domcontentloaded",
});
const endTime = performance.now() - startTime;
const { issues, pageUrl, documentTitle, meta, automateable } = results;
console.log([{ meta, automateable }, ["fast_axecore: time took", endTime]]);
// valid list
assert(Array.isArray(issues));
assert(typeof pageUrl === "string");
assert(typeof documentTitle === "string");
assert(meta.warningCount === 9);
assert(meta.errorCount === 31);
writeFileSync(
testInfo.outputPath("axe-core.json"),
JSON.stringify(results, null, 2),
"utf8",
);
writeFileSync(
testInfo.outputPath("axe-core_stats.json"),
JSON.stringify(
{
mock: "[drakeMock]",
htmlSize: drakeMock.length,
duration: endTime,
errors: meta.errorCount,
warnings: meta.warningCount,
runner: ["fast_axecore"],
},
null,
2,
),
"utf8",
);
});