@d-zero/a11y-check-scenarios 0.4.20 → 0.4.22
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/README.md +272 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1 +1,272 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @d-zero/a11y-check-scenarios
|
|
2
|
+
|
|
3
|
+
Webサイトのアクセシビリティをチェックするためのシナリオコレクション
|
|
4
|
+
|
|
5
|
+
## インストール
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @d-zero/a11y-check-scenarios puppeteer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
または
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @d-zero/a11y-check-scenarios puppeteer
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 概要
|
|
18
|
+
|
|
19
|
+
`@d-zero/a11y-check-scenarios` は、Webページのアクセシビリティを自動的にチェックするための定義済みシナリオを提供するパッケージです。Puppeteerを使用してブラウザを制御し、WCAG(Web Content Accessibility Guidelines)の達成基準に基づいた検証を実行します。
|
|
20
|
+
|
|
21
|
+
このパッケージには2つの主要なシナリオが含まれています:
|
|
22
|
+
|
|
23
|
+
- **scenario01**: WCAG達成基準に基づく視覚的検証(スクリーンショット生成)
|
|
24
|
+
- **scenario02**: ナビゲーション要素の抽出と分析
|
|
25
|
+
|
|
26
|
+
### 主な特徴
|
|
27
|
+
|
|
28
|
+
- WCAGの達成基準に基づいた自動チェック
|
|
29
|
+
- スクリーンショットベースの視覚的検証
|
|
30
|
+
- キャッシュ機能による効率的な再実行
|
|
31
|
+
- HTML形式のレポート生成
|
|
32
|
+
- TypeScript完全サポート
|
|
33
|
+
|
|
34
|
+
## scenario01の説明
|
|
35
|
+
|
|
36
|
+
scenario01は、WCAGの以下の達成基準をテストするシナリオです。各テストでスクリーンショットを撮影し、視覚的に検証できるHTML形式のレポートを生成します。
|
|
37
|
+
|
|
38
|
+
### テストされるWCAG達成基準
|
|
39
|
+
|
|
40
|
+
#### 1. SC 2.5.8 Target Size (Minimum) - ターゲットサイズ(最小)
|
|
41
|
+
|
|
42
|
+
**検証内容:**
|
|
43
|
+
|
|
44
|
+
- インタラクティブ要素(`a`、`button`、`input`、`select`、`textarea`、`label`、`summary`)のターゲットサイズが24px × 24px以上であるかをチェック
|
|
45
|
+
- 基準を満たさない要素を赤い半透明の矩形と円でマーキング
|
|
46
|
+
|
|
47
|
+
**視覚化:**
|
|
48
|
+
|
|
49
|
+
- 24px × 24px未満の要素: 赤い半透明の矩形と中心に赤い円(半径12px)で表示
|
|
50
|
+
- すべてのインタラクティブ要素: 赤い半透明の矩形で境界を表示
|
|
51
|
+
|
|
52
|
+
#### 2. SC 1.4.4 Text Resize - テキストのリサイズ
|
|
53
|
+
|
|
54
|
+
**検証内容:**
|
|
55
|
+
|
|
56
|
+
- テキストを200%に拡大した際にコンテンツや機能が損なわれないかをチェック
|
|
57
|
+
- キャプションと画像化された文字を除く、すべてのテキストを200%に拡大
|
|
58
|
+
|
|
59
|
+
**検証方法:**
|
|
60
|
+
|
|
61
|
+
- ルート要素の`font-size`を200%に設定してスクリーンショットを撮影
|
|
62
|
+
|
|
63
|
+
#### 3. SC 1.4.12 Text Spacing - テキストの間隔
|
|
64
|
+
|
|
65
|
+
**検証内容:**
|
|
66
|
+
|
|
67
|
+
- 以下のテキスト間隔が設定された際にコンテンツや機能が損なわれないかをチェック:
|
|
68
|
+
- 行の高さ(行間): フォントサイズの1.5倍以上
|
|
69
|
+
- 段落の間隔: フォントサイズの2倍以上
|
|
70
|
+
- 文字の間隔(字間): フォントサイズの0.12倍以上
|
|
71
|
+
- 単語の間隔: フォントサイズの0.16倍以上
|
|
72
|
+
|
|
73
|
+
**検証方法:**
|
|
74
|
+
|
|
75
|
+
- すべての要素に上記のスタイルを強制的に適用してスクリーンショットを撮影
|
|
76
|
+
|
|
77
|
+
### 出力形式
|
|
78
|
+
|
|
79
|
+
scenario01は各テストごとに以下の形式でHTMLレポートを生成します:
|
|
80
|
+
|
|
81
|
+
- ファイル名: `a11y-check-scenario01_[テスト名].html`
|
|
82
|
+
- 内容: 各ページ・各画面サイズごとのスクリーンショット一覧
|
|
83
|
+
- スタイル: 黒背景で画像を並べて表示
|
|
84
|
+
|
|
85
|
+
## scenario02の説明
|
|
86
|
+
|
|
87
|
+
scenario02は、Webページからナビゲーション要素を抽出するシナリオです。
|
|
88
|
+
|
|
89
|
+
### 検証内容
|
|
90
|
+
|
|
91
|
+
以下のセレクタにマッチする要素のouterHTMLを収集します:
|
|
92
|
+
|
|
93
|
+
- `header`: ヘッダー要素
|
|
94
|
+
- `nav`: ナビゲーション要素
|
|
95
|
+
- `footer`: フッター要素
|
|
96
|
+
- `[class*='nav' i]`: クラス名に"nav"を含む要素(大文字小文字を区別しない)
|
|
97
|
+
|
|
98
|
+
### 出力形式
|
|
99
|
+
|
|
100
|
+
各要素のHTMLコードを抽出し、分析用のデータとして保存します。
|
|
101
|
+
|
|
102
|
+
## 使用例
|
|
103
|
+
|
|
104
|
+
### 基本的な使用方法
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { scenario01, scenario02 } from '@d-zero/a11y-check-scenarios';
|
|
108
|
+
import puppeteer from 'puppeteer';
|
|
109
|
+
|
|
110
|
+
const browser = await puppeteer.launch();
|
|
111
|
+
const page = await browser.newPage();
|
|
112
|
+
|
|
113
|
+
// scenario01を実行
|
|
114
|
+
const scenario1 = scenario01();
|
|
115
|
+
await page.goto('https://example.com');
|
|
116
|
+
const result1 = await scenario1.exec(page, 'desktop', console.log);
|
|
117
|
+
|
|
118
|
+
// scenario02を実行
|
|
119
|
+
const scenario2 = scenario02();
|
|
120
|
+
await page.goto('https://example.com');
|
|
121
|
+
const result2 = await scenario2.exec(page, 'desktop', console.log);
|
|
122
|
+
|
|
123
|
+
await browser.close();
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### オプション付きの使用方法
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { scenario01, scenario02 } from '@d-zero/a11y-check-scenarios';
|
|
130
|
+
|
|
131
|
+
// キャッシュを無効化
|
|
132
|
+
const scenario1 = scenario01({ cache: false });
|
|
133
|
+
|
|
134
|
+
// カスタムキャッシュディレクトリを指定
|
|
135
|
+
const scenario2 = scenario02({ cacheDir: '/path/to/cache' });
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 分析結果の生成
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { scenario01 } from '@d-zero/a11y-check-scenarios';
|
|
142
|
+
import puppeteer from 'puppeteer';
|
|
143
|
+
|
|
144
|
+
const browser = await puppeteer.launch();
|
|
145
|
+
const page = await browser.newPage();
|
|
146
|
+
const scenario = scenario01();
|
|
147
|
+
|
|
148
|
+
// 複数のページをチェック
|
|
149
|
+
const urls = [
|
|
150
|
+
'https://example.com',
|
|
151
|
+
'https://example.com/about',
|
|
152
|
+
'https://example.com/contact',
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
const allResults = [];
|
|
156
|
+
|
|
157
|
+
for (const url of urls) {
|
|
158
|
+
await page.goto(url);
|
|
159
|
+
const result = await scenario.exec(page, 'desktop', console.log);
|
|
160
|
+
if (result.needAnalysis) {
|
|
161
|
+
allResults.push(...result.needAnalysis);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// HTML形式のレポートを生成
|
|
166
|
+
await scenario.analyze(allResults, console.log);
|
|
167
|
+
|
|
168
|
+
await browser.close();
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 複数の画面サイズでテスト
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { scenario01 } from '@d-zero/a11y-check-scenarios';
|
|
175
|
+
import puppeteer from 'puppeteer';
|
|
176
|
+
|
|
177
|
+
const browser = await puppeteer.launch();
|
|
178
|
+
const page = await browser.newPage();
|
|
179
|
+
const scenario = scenario01();
|
|
180
|
+
|
|
181
|
+
const allResults = [];
|
|
182
|
+
|
|
183
|
+
// デスクトップサイズ
|
|
184
|
+
await page.setViewport({ width: 1920, height: 1080 });
|
|
185
|
+
await page.goto('https://example.com');
|
|
186
|
+
const desktopResult = await scenario.exec(page, 'desktop', console.log);
|
|
187
|
+
if (desktopResult.needAnalysis) {
|
|
188
|
+
allResults.push(...desktopResult.needAnalysis);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// タブレットサイズ
|
|
192
|
+
await page.setViewport({ width: 768, height: 1024 });
|
|
193
|
+
await page.goto('https://example.com');
|
|
194
|
+
const tabletResult = await scenario.exec(page, 'tablet', console.log);
|
|
195
|
+
if (tabletResult.needAnalysis) {
|
|
196
|
+
allResults.push(...tabletResult.needAnalysis);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// モバイルサイズ
|
|
200
|
+
await page.setViewport({ width: 375, height: 667 });
|
|
201
|
+
await page.goto('https://example.com');
|
|
202
|
+
const mobileResult = await scenario.exec(page, 'mobile', console.log);
|
|
203
|
+
if (mobileResult.needAnalysis) {
|
|
204
|
+
allResults.push(...mobileResult.needAnalysis);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// レポート生成
|
|
208
|
+
await scenario.analyze(allResults, console.log);
|
|
209
|
+
|
|
210
|
+
await browser.close();
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## API
|
|
214
|
+
|
|
215
|
+
### scenario01(options?: ScenarioOptions)
|
|
216
|
+
|
|
217
|
+
WCAG達成基準に基づく視覚的検証シナリオを作成します。
|
|
218
|
+
|
|
219
|
+
**パラメータ:**
|
|
220
|
+
|
|
221
|
+
- `options.cache` (boolean, optional): キャッシュを使用するかどうか(デフォルト: true)
|
|
222
|
+
- `options.cacheDir` (string, optional): キャッシュディレクトリのパス
|
|
223
|
+
|
|
224
|
+
**戻り値:**
|
|
225
|
+
|
|
226
|
+
- Scenarioオブジェクト
|
|
227
|
+
|
|
228
|
+
### scenario02(options?: ScenarioOptions)
|
|
229
|
+
|
|
230
|
+
ナビゲーション要素を抽出するシナリオを作成します。
|
|
231
|
+
|
|
232
|
+
**パラメータ:**
|
|
233
|
+
|
|
234
|
+
- `options.cache` (boolean, optional): キャッシュを使用するかどうか(デフォルト: true)
|
|
235
|
+
- `options.cacheDir` (string, optional): キャッシュディレクトリのパス
|
|
236
|
+
|
|
237
|
+
**戻り値:**
|
|
238
|
+
|
|
239
|
+
- Scenarioオブジェクト
|
|
240
|
+
|
|
241
|
+
### Scenarioオブジェクトのメソッド
|
|
242
|
+
|
|
243
|
+
#### exec(page: Page, sizeName: string, logger: Function)
|
|
244
|
+
|
|
245
|
+
シナリオを実行します。
|
|
246
|
+
|
|
247
|
+
**パラメータ:**
|
|
248
|
+
|
|
249
|
+
- `page`: Puppeteerのページオブジェクト
|
|
250
|
+
- `sizeName`: 画面サイズの名前(例: 'desktop', 'mobile')
|
|
251
|
+
- `logger`: ログ出力用の関数
|
|
252
|
+
|
|
253
|
+
**戻り値:**
|
|
254
|
+
|
|
255
|
+
- `needAnalysis`: 分析が必要なデータの配列
|
|
256
|
+
|
|
257
|
+
#### analyze(results: NeedAnalysis[], logger: Function)
|
|
258
|
+
|
|
259
|
+
収集したデータを分析し、レポートを生成します。
|
|
260
|
+
|
|
261
|
+
**パラメータ:**
|
|
262
|
+
|
|
263
|
+
- `results`: execメソッドで収集したデータの配列
|
|
264
|
+
- `logger`: ログ出力用の関数
|
|
265
|
+
|
|
266
|
+
## ライセンス
|
|
267
|
+
|
|
268
|
+
MIT
|
|
269
|
+
|
|
270
|
+
## 作者
|
|
271
|
+
|
|
272
|
+
D-ZERO
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/a11y-check-scenarios",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.22",
|
|
4
4
|
"description": "Accessibility Checker Scenario Collection",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"clean": "tsc --build --clean"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@d-zero/a11y-check-core": "0.6.
|
|
27
|
-
"@d-zero/shared": "0.
|
|
26
|
+
"@d-zero/a11y-check-core": "0.6.8",
|
|
27
|
+
"@d-zero/shared": "0.18.0",
|
|
28
28
|
"ansi-colors": "4.1.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"puppeteer": "24.
|
|
31
|
+
"puppeteer": "24.37.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"puppeteer": "24.
|
|
34
|
+
"puppeteer": "24.37.2"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "a6d7b36c485bbc0782375c6e1ad0d0606f423e97"
|
|
37
37
|
}
|