@d-zero/a11y-check-axe-scenario 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/axe.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import AxePuppeteer from '@axe-core/puppeteer';
|
|
1
2
|
import { createScenario } from '@d-zero/a11y-check-core';
|
|
2
3
|
import { Cache } from '@d-zero/shared/cache';
|
|
3
4
|
import { convertResultsFromViolations } from './convert-results-from-violations.js';
|
|
@@ -5,13 +6,14 @@ const scenarioId = 'a11y-check/axe';
|
|
|
5
6
|
export default createScenario((options) => {
|
|
6
7
|
const cache = new Cache(scenarioId, options?.cacheDir);
|
|
7
8
|
return {
|
|
9
|
+
modulePath: import.meta.url,
|
|
8
10
|
id: scenarioId,
|
|
9
11
|
async exec(page, sizeName, log) {
|
|
10
12
|
if (options?.cache === false) {
|
|
11
13
|
await cache.clear();
|
|
12
14
|
}
|
|
13
15
|
const axeLog = (message) => log(`🪓 ${message}`);
|
|
14
|
-
const key =
|
|
16
|
+
const key = page.url() + '#' + sizeName;
|
|
15
17
|
const cached = await cache.load(key, (key, value) => {
|
|
16
18
|
if (key === 'timestamp') {
|
|
17
19
|
return new Date(Date.parse(value));
|
|
@@ -23,10 +25,13 @@ export default createScenario((options) => {
|
|
|
23
25
|
violations: await convertResultsFromViolations(page, cached, sizeName, options?.screenshot ?? false, axeLog),
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
|
-
const axeResults = await page
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const axeResults = await new AxePuppeteer(page)
|
|
29
|
+
.configure({
|
|
30
|
+
locale: {
|
|
31
|
+
lang: options?.lang ?? 'ja',
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
.analyze();
|
|
30
35
|
await cache.store(key, axeResults);
|
|
31
36
|
return {
|
|
32
37
|
violations: await convertResultsFromViolations(page, axeResults, sizeName, options?.screenshot ?? false, axeLog),
|
|
@@ -16,9 +16,10 @@ export async function convertResultsFromNode(page, node, screenshot, log) {
|
|
|
16
16
|
let screenshotName = null;
|
|
17
17
|
if (screenshot && target) {
|
|
18
18
|
log(`Screenshot: ${target}`);
|
|
19
|
-
const url =
|
|
19
|
+
const url = page.url();
|
|
20
20
|
const ssName = hash(url + target) + '.png';
|
|
21
|
-
const
|
|
21
|
+
const el = await page.waitForSelector(target);
|
|
22
|
+
const elementScreenshot = await el?.screenshot({
|
|
22
23
|
path: path.resolve(process.cwd(), '.cache', ssName),
|
|
23
24
|
});
|
|
24
25
|
if (elementScreenshot) {
|
|
@@ -21,7 +21,7 @@ export async function convertResultsFromViolations(page, axeResults, sizeName, s
|
|
|
21
21
|
const explanation = inferExplanation(violation.id, node, nodeResult?.style ?? null);
|
|
22
22
|
results.push({
|
|
23
23
|
id: '',
|
|
24
|
-
url:
|
|
24
|
+
url: page.url(),
|
|
25
25
|
tool: `${axeResults.testEngine.name} (v${axeResults.testEngine.version})`,
|
|
26
26
|
timestamp: new Date(axeResults.timestamp),
|
|
27
27
|
component: nodeResult?.landmark ?? null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/a11y-check-axe-scenario",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Accessibility Checker Axe Scenario",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,13 +24,18 @@
|
|
|
24
24
|
"clean": "tsc --build --clean"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@
|
|
27
|
+
"@axe-core/puppeteer": "4.10.1",
|
|
28
|
+
"@d-zero/a11y-check-core": "0.4.0",
|
|
28
29
|
"@d-zero/db-wcag": "1.0.0-alpha.1",
|
|
29
|
-
"@d-zero/shared": "0.
|
|
30
|
+
"@d-zero/shared": "0.8.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"axe-core": "4.10.3",
|
|
34
|
+
"puppeteer": "24.9.0"
|
|
34
35
|
},
|
|
35
|
-
"
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"axe-core": "4.10.3",
|
|
38
|
+
"puppeteer": "24.8.2"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "4e9cc7b87e0fef91b6f2d4edfb66ca9134b2491b"
|
|
36
41
|
}
|