web-corders-vrt 0.1.3 → 0.1.5

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.
@@ -11,7 +11,12 @@
11
11
  "Bash(node dist/bin/vrt.js run --before https://www.video.unext.jp --after http://localhost:3000 --paths /lp/ppd_contents_h --no-open)",
12
12
  "Bash(open vrt-results/2026-03-02T05-02-45/report.html)",
13
13
  "Bash(open vrt-results/2026-03-02T06-41-44/report.html)",
14
- "Bash(open vrt-results/2026-03-02T06-49-09/report.html)"
14
+ "Bash(open vrt-results/2026-03-02T06-49-09/report.html)",
15
+ "Bash(node dist/bin/vrt.js run --before https://www.video.unext.jp --after http://localhost:3000 --paths /lp/unext_mobile_a263 --no-open)",
16
+ "Bash(node -e \"const r=JSON.parse\\(require\\(''fs''\\).readFileSync\\(''/dev/stdin'',''utf8''\\)\\); r.results.forEach\\(t => { console.log\\(t.viewport.type, ''before:'', t.comparison.dimensions.beforeHeight, ''after:'', t.comparison.dimensions.afterHeight, ''aligned:'', t.comparison.alignmentUsed ?? false, ''shifted:'', t.comparison.shiftedRows ?? 0, ''diff:'', t.comparison.diffPercentage.toFixed\\(2\\)+''%''\\) }\\)\")",
17
+ "Bash(node -e \"const r=JSON.parse\\(require\\(''fs''\\).readFileSync\\(''/dev/stdin'',''utf8''\\)\\); r.results.forEach\\(t => { console.log\\(t.viewport.type, ''width:'', t.comparison.dimensions.width, ''beforeH:'', t.comparison.dimensions.beforeHeight, ''afterH:'', t.comparison.dimensions.afterHeight\\) }\\)\")",
18
+ "Bash(node -e \"const r=JSON.parse\\(require\\(''fs''\\).readFileSync\\(''/dev/stdin'',''utf8''\\)\\); r.results.forEach\\(t => { console.log\\(t.viewport.type, ''aligned:'', t.comparison.alignmentUsed, ''shifted:'', t.comparison.shiftedRows, ''diff:'', t.comparison.diffPercentage.toFixed\\(2\\)+''%'', ''beforeH:'', t.comparison.dimensions.beforeHeight, ''afterH:'', t.comparison.dimensions.afterHeight\\) }\\)\")",
19
+ "Bash(open vrt-results/2026-03-02T07-22-33/report.html)"
15
20
  ]
16
21
  }
17
22
  }
package/README.md CHANGED
@@ -2,27 +2,34 @@
2
2
 
3
3
  Webページのビジュアルリグレッションテスト (VRT) を行うCLIツール。
4
4
 
5
- 本番環境と開発環境のスクリーンショットをピクセル単位で比較し、差分を検出する。テスト結果は人間向け(HTMLレポート)とLLM/Claude向け(JSONレポート + diff画像)の両方で出力される。
5
+ 本番環境と開発/プレビュー環境のスクリーンショットの差分を検出する。
6
+ テスト結果は人間向け(HTMLレポート + diff画像)とLLM/Claude向け(JSONレポート)の両方で出力される。
6
7
 
7
8
  ## セットアップ
8
9
 
9
- インストール不要。`npx` で直接実行できる。初回のみ Playwright のブラウザが必要:
10
+ 初回のみ Playwright のブラウザが必要:
10
11
 
11
12
  ```bash
12
13
  npx playwright install chromium
13
14
  ```
14
15
 
16
+ `init` コマンドで、Claude Codeのスキルファイル (`.claude/skills/web-corders-vrt/SKILL.md`) を自動生成できる。
17
+
18
+ ```bash
19
+ npx web-corders-vrt init --refDomain https://example.com
20
+ ```
21
+
15
22
  ## 基本的な使い方
16
23
 
17
24
  ```bash
18
25
  npx web-corders-vrt run \
19
- --before https://example.com \
26
+ --reference https://production.com \
20
27
  --after http://localhost:3000 \
21
28
  --paths /,/about,/pricing
22
29
  ```
23
30
 
24
- - `--before` — 比較元URL(本番環境)
25
- - `--after` — 比較先URL(開発環境 / ステージング)
31
+ - `--reference` — リファレンスのプロトコル+ドメイン(本番環境)
32
+ - `--after` — 比較するプロトコル+ドメイン(開発 / プレビュー環境)
26
33
  - `--paths` — テスト対象のページパス(カンマ区切り)
27
34
 
28
35
  実行すると `./vrt-results/` 以下にタイムスタンプ付きのディレクトリが生成され、スクリーンショット・diff画像・レポートが保存される。
@@ -34,10 +41,10 @@ vrt-results/2026-02-28T10-00-00/
34
41
  ├── report.json # JSON レポート(Claude/LLM向け)
35
42
  ├── report.html # HTML レポート(人間向け・ブラウザで開く)
36
43
  └── screenshots/
37
- ├── top--sp--before.png
44
+ ├── top--sp--reference.png
38
45
  ├── top--sp--after.png
39
46
  ├── top--sp--diff.png
40
- ├── top--pc--before.png
47
+ ├── top--pc--reference.png
41
48
  ├── top--pc--after.png
42
49
  └── top--pc--diff.png
43
50
  ```
@@ -62,30 +69,16 @@ vrt-results/2026-02-28T10-00-00/
62
69
  "diffPercentage": 2.35,
63
70
  "diffPixelCount": 12040,
64
71
  },
65
- "diffRegions": [
66
- {
67
- "id": 1,
68
- "boundingBox": { "x": 0, "y": 480, "width": 750, "height": 200 },
69
- "locationHint": {
70
- "verticalPosition": "upper",
71
- "horizontalPosition": "full-width",
72
- "fromTopPx": 480,
73
- "estimatedElement": "Likely a hero section or banner",
74
- },
75
- },
76
- ],
77
72
  },
78
73
  ],
79
74
  }
80
75
  ```
81
76
 
82
- `diffRegions` の `locationHint` は、差分がページのどの位置にあるかを示す。Claudeがこれを読むことで、修正すべきCSS/HTMLの場所を推定できる。
83
-
84
77
  ## オプション一覧
85
78
 
86
79
  | オプション | デフォルト | 説明 |
87
80
  | -------------------- | ---------- | ----------------------------------------------------------------------- |
88
- | `--before <url>` | (必須) | 比較元URL(本番環境) |
81
+ | `--reference <url>` | (必須) | リファレンスURL(本番環境) |
89
82
  | `--after <url>` | (必須) | 比較先URL(開発環境 / ステージング) |
90
83
  | `--paths <paths>` | (必須) | テスト対象のページパス(カンマ区切り) |
91
84
  | `--threshold <n>` | `0.1` | 差分許容率(%)。これ以下の差分はPASS扱い |
@@ -95,57 +88,50 @@ vrt-results/2026-02-28T10-00-00/
95
88
 
96
89
  ビューポートはSP(375x812)とPC(1440x900)の2種類で固定。フルページスクリーンショットを取得し、結果は `./vrt-results/` に出力される。
97
90
 
91
+ ## Claude Code連携
92
+
93
+ ### スキルファイルの仕組み
94
+
95
+ `init`で生成される `.claude/skills/web-corders-vrt/SKILL.md` には以下の手順が記述される:
96
+
97
+ 1. 開発サーバーを起動
98
+ 2. VRTコマンドを実行
99
+ 3. `report.json` を読んで差分を確認
100
+ 4. diff画像を視覚的に確認
101
+ 5. diff画像からCSS/HTMLの修正箇所を特定
102
+ 6. コードを修正
103
+ 7. 再度VRTを実行して確認
104
+
105
+ 以降はCaludeに「VRTして」とか言うだけで使ってくれる はず。
106
+
98
107
  ## 実用的な例
99
108
 
100
109
  ### 動的要素を隠してテスト
101
110
 
102
- 広告バナーやクッキー同意バーなど、毎回変わる要素を非表示にする:
111
+ テスト対象外にしたい要素を非表示にする。
103
112
 
104
113
  ```bash
105
114
  npx web-corders-vrt run \
106
- --before https://example.com \
115
+ --reference https://example.com \
107
116
  --after http://localhost:3000 \
108
117
  --paths / \
109
118
  --hide ".cookie-banner,.ad-slot,[data-testid='live-chat']"
110
119
  ```
111
120
 
121
+ Next.jsツールバーはデフォルトで非表示。
122
+
112
123
  ### 差分許容率を緩めに設定
113
124
 
114
125
  フォントレンダリング差異などを無視したい場合:
115
126
 
116
127
  ```bash
117
128
  npx web-corders-vrt run \
118
- --before https://example.com \
129
+ --reference https://example.com \
119
130
  --after http://localhost:3000 \
120
131
  --paths / \
121
132
  --threshold 1
122
133
  ```
123
134
 
124
- ## Claude Code連携
125
-
126
- `vrt init` コマンドで、Claude Codeのスキルファイル (`.claude/commands/vrt.md`) を自動生成できる。
127
-
128
- ```bash
129
- npx web-corders-vrt init \
130
- --before https://example.com \
131
- --after http://localhost:3000 \
132
- --paths /,/about,/pricing
133
- ```
134
-
135
- 生成されたファイルをリポジトリにコミットすると、Claude Code上で `/vrt` コマンドを実行するだけで、VRTの実行 → 結果の読み取り → 差分箇所の特定 → コード修正 → 再テストまでを自律的に行えるようになる。
136
-
137
- ### スキルファイルの仕組み
138
-
139
- 生成される `.claude/commands/vrt.md` には以下の手順が記述される:
140
-
141
- 1. 開発サーバーを起動
142
- 2. VRTコマンドを実行
143
- 3. `report.json` を読んで差分を確認
144
- 4. diff画像を視覚的に確認
145
- 5. `locationHint` からCSS/HTMLの修正箇所を特定
146
- 6. コードを修正
147
- 7. 再度VRTを実行して確認
148
-
149
135
  ## 広告・計測系スクリプトのブロック
150
136
 
151
137
  以下のドメインへのリクエストは自動的にブロックされる。見た目のテストに不要であり、ページ読み込み速度を改善するため。
package/bin/vrt.ts CHANGED
@@ -14,7 +14,7 @@ program
14
14
  program
15
15
  .command("run")
16
16
  .description("Run visual regression tests")
17
- .requiredOption("--before <url>", "Baseline URL (production)")
17
+ .requiredOption("--reference <url>", "Reference URL (production)")
18
18
  .requiredOption("--after <url>", "Comparison URL (local/staging)")
19
19
  .requiredOption("--paths <paths>", "Page paths to compare (comma-separated)")
20
20
  .option("--threshold <n>", "Diff tolerance percentage", "0.1")
@@ -26,7 +26,7 @@ program
26
26
  const parsed = cliOptionsSchema.parse(rawOptions);
27
27
 
28
28
  const options: ResolvedOptions = {
29
- beforeUrl: parsed.before,
29
+ referenceUrl: parsed.reference,
30
30
  afterUrl: parsed.after,
31
31
  paths: parsed.paths,
32
32
  threshold: parsed.threshold,
@@ -50,22 +50,12 @@ program
50
50
  program
51
51
  .command("init")
52
52
  .description(
53
- "Generate .claude/commands/vrt.md skill file for this repository",
53
+ "Generate .claude/skills/web-corders-vrt/SKILL.md for this repository",
54
54
  )
55
- .requiredOption("--before <url>", "Baseline URL (production)")
56
- .requiredOption("--after <url>", "Comparison URL (local/staging)")
57
- .requiredOption("--paths <paths>", "Page paths to compare (comma-separated)")
58
- .option("--threshold <n>", "Diff tolerance percentage", "0.1")
59
- .option("--hide <selectors>", "CSS selectors to hide (comma-separated)")
55
+ .requiredOption("--refDomain <domain>", "Reference domain URL (production)")
60
56
  .action(async (options) => {
61
57
  try {
62
- await runInit({
63
- before: options.before,
64
- after: options.after,
65
- paths: options.paths,
66
- threshold: parseFloat(options.threshold),
67
- hide: options.hide,
68
- });
58
+ await runInit({ refDomain: options.refDomain });
69
59
  } catch (error) {
70
60
  if (error instanceof Error) {
71
61
  console.error(`Error: ${error.message}`);