@d-zero/a11y-check-axe-scenario 0.3.0 → 0.4.0
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 +11 -5
- package/dist/convert-results-from-node.d.ts +1 -1
- package/dist/convert-results-from-node.js +3 -2
- package/dist/convert-results-from-violations.d.ts +1 -1
- package/dist/convert-results-from-violations.js +2 -2
- package/dist/infer-explanation.js +2 -2
- package/dist/paragraph.d.ts +10 -0
- package/dist/paragraph.js +14 -0
- package/package.json +11 -6
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,15 @@ 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,
|
|
10
|
+
moduleParams: JSON.stringify(options ?? {}),
|
|
8
11
|
id: scenarioId,
|
|
9
12
|
async exec(page, sizeName, log) {
|
|
10
13
|
if (options?.cache === false) {
|
|
11
14
|
await cache.clear();
|
|
12
15
|
}
|
|
13
16
|
const axeLog = (message) => log(`🪓 ${message}`);
|
|
14
|
-
const key =
|
|
17
|
+
const key = page.url() + '#' + sizeName;
|
|
15
18
|
const cached = await cache.load(key, (key, value) => {
|
|
16
19
|
if (key === 'timestamp') {
|
|
17
20
|
return new Date(Date.parse(value));
|
|
@@ -23,10 +26,13 @@ export default createScenario((options) => {
|
|
|
23
26
|
violations: await convertResultsFromViolations(page, cached, sizeName, options?.screenshot ?? false, axeLog),
|
|
24
27
|
};
|
|
25
28
|
}
|
|
26
|
-
const axeResults = await page
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
const axeResults = await new AxePuppeteer(page)
|
|
30
|
+
.configure({
|
|
31
|
+
locale: {
|
|
32
|
+
lang: options?.lang ?? 'ja',
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
.analyze();
|
|
30
36
|
await cache.store(key, axeResults);
|
|
31
37
|
return {
|
|
32
38
|
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) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { convertResultsFromNode } from './convert-results-from-node.js';
|
|
2
2
|
import { detectLevel } from './detect-level.js';
|
|
3
3
|
import { inferExplanation } from './infer-explanation.js';
|
|
4
|
-
import { p } from './
|
|
4
|
+
import { p } from './paragraph.js';
|
|
5
5
|
import { tagsToSCs } from './tags-to-scs.js';
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -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,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { colorContrastCheck, ColorContrastError } from '@d-zero/a11y-check-core';
|
|
2
|
-
import { br, p } from './
|
|
2
|
+
import { br, p } from './paragraph.js';
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @param id
|
|
@@ -132,7 +132,7 @@ export function inferExplanation(id, node, style) {
|
|
|
132
132
|
}
|
|
133
133
|
case ColorContrastError.DOES_NOT_DETERMINE_BACKGROUND: {
|
|
134
134
|
needCheck = 'WARNING';
|
|
135
|
-
message = '
|
|
135
|
+
message = '背景色が判定できなかったので#FFFFFFとして判定しています。';
|
|
136
136
|
contrastResult = style
|
|
137
137
|
? colorContrastCheck({
|
|
138
138
|
...style,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/a11y-check-axe-scenario",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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.2",
|
|
28
|
+
"@d-zero/a11y-check-core": "0.5.0",
|
|
28
29
|
"@d-zero/db-wcag": "1.0.0-alpha.1",
|
|
29
|
-
"@d-zero/shared": "0.
|
|
30
|
+
"@d-zero/shared": "0.9.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"axe-core": "4.10.3",
|
|
34
|
+
"puppeteer": "24.10.1"
|
|
34
35
|
},
|
|
35
|
-
"
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"axe-core": "4.10.3",
|
|
38
|
+
"puppeteer": "24.10.1"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "04c6969564182c36ee38ef41e78130936dfa4863"
|
|
36
41
|
}
|