@iqual/playwright-vrt 0.1.9 → 0.1.10

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 CHANGED
@@ -1,19 +1,39 @@
1
- # @iqual/playwright-vrt
1
+ # iqual Playwright VRT
2
2
 
3
- **Standalone Visual Regression Testing CLI tool using Playwright**
3
+ **Standalone Visual Regression Testing CLI tool using [Playwright](https://github.com/microsoft/playwright) 🎭**
4
4
 
5
- Zero-installation visual regression testing that runs directly in CI/CD. Test visual differences across multiple projects with a single config file.
5
+ Zero-installation visual regression testing (VRT) that runs directly in CI/CD. Scale your visual regression testing efforst with a simple config file.
6
6
 
7
7
  ## Quick Start
8
8
 
9
+ ```
10
+ bunx playwright install chromium
11
+
12
+ bunx @iqual/playwright-vrt run \
13
+ --reference https://production.example.com \
14
+ --test https://staging.example.com
15
+ ```
16
+
17
+ That's it! The tool will:
18
+ - Auto-discover URLs from your sitemap (or crawl the homepage)
19
+ - Create baseline screenshots from the reference URL
20
+ - Compare against test environment
21
+ - Generate visual diff report in `playwright-report/`
22
+
23
+ > [!TIP]
24
+ > Using `--reference` is optional, but requires a baseline if it is not set. You can always (re-)create a baseline with `--udpate-baseline`.
25
+
9
26
  ## Why Use This?
10
27
 
11
- - **No per-project setup** - Just run `bunx @iqual/playwright-vrt run --test <url>` or `--config <file>`
28
+ - **No per-project code setup** - Just run `bunx @iqual/playwright-vrt run --test <url>` or `--config <file>`
12
29
  - **Smart defaults** - Works without a config file
13
30
  - **Flexible** - Use CLI args for quick tests, config files for complex setups
14
- - **CI/CD optimized** - Caches baselines, auto-detects config changes
31
+ - **CI/CD optimized** - Allows caching baselines, auto-detects config changes
15
32
 
16
- **Option 1: Quick test with URL only**:
33
+ ## Usage with config
34
+
35
+ For more advanced setups, or to allow the generation of configuration files it is also possible
36
+ to add a `playwright-vrt.config.json` config file in your current working directory:
17
37
 
18
38
  ```json
19
39
  {
@@ -24,37 +44,13 @@ Zero-installation visual regression testing that runs directly in CI/CD. Test vi
24
44
  }
25
45
  ```
26
46
 
47
+ Then run the VRT using the `--config` flag:
48
+
27
49
  ```bash
28
50
  # Run with config file (includes both URLs)
29
51
  bunx @iqual/playwright-vrt run --config ./playwright-vrt.config.json
30
-
31
- # Or override test URL from config
32
- bunx @iqual/playwright-vrt run \
33
- --test https://preview-branch.staging.com \
34
- --config ./playwright-vrt.config.json
35
-
36
- # Or compare production vs staging
37
- bunx @iqual/playwright-vrt run \
38
- --reference https://production.example.com \
39
- --test https://staging.example.com
40
52
  ```
41
53
 
42
- ```bash
43
- # First run: create baseline from test URL
44
- bunx @iqual/playwright-vrt run --test https://staging.example.com --update-baseline
45
-
46
- # Subsequent runs: compare against cached baseline
47
- bunx @iqual/playwright-vrt run --test https://staging.example.com
48
- ```
49
-
50
- **Option 2: Use config file** (`playwright-vrt.config.json`):
51
-
52
- That's it! The tool will:
53
- - Auto-discover URLs from your sitemap (or use defaults)
54
- - Create baseline screenshots from reference URL (or test URL on first run)
55
- - Compare against test environment
56
- - Generate visual diff report in `playwright-report/`
57
-
58
54
  ## Features
59
55
 
60
56
  - ✅ **Zero installation** - Run with `bunx`, no setup needed
@@ -143,7 +139,7 @@ The tool intelligently caches URLs and baseline snapshots based on your **config
143
139
  The cache is automatically invalidated and regenerated when:
144
140
 
145
141
  - Configuration changes (URLs, viewports, filters, thresholds, etc.)
146
- - Test file (`vrt.spec.ts`) changes in the package
142
+ - Test file (`vrt.spec.js`) changes in the package
147
143
 
148
144
  The hash is based on the **final merged config object**, not the config file itself.
149
145
 
@@ -164,7 +160,8 @@ This regenerates both URLs and baseline snapshots from the reference system rega
164
160
  ## GitHub Actions
165
161
 
166
162
  ```yaml
167
- - uses: oven-sh/setup-bun@v1
163
+ - name: Setup Bun
164
+ uses: oven-sh/setup-bun@v1
168
165
 
169
166
  # Cache baseline snapshots to avoid hitting production on every run
170
167
  - uses: actions/cache@v4
@@ -173,12 +170,20 @@ This regenerates both URLs and baseline snapshots from the reference system rega
173
170
  key: vrt-baseline-${{ hashFiles('playwright-vrt.config.json') }}
174
171
  restore-keys: vrt-baseline-
175
172
 
176
- - run: |
173
+ - name: Install Playwright VRT dependencies
174
+ shell: bash
175
+ run: |
176
+ bunx playwright install chromium
177
+
178
+ - name: Run Visual regression tests
179
+ shell: bash
180
+ run: |
177
181
  bunx @iqual/playwright-vrt run \
178
- --reference https://production.com \
179
- --test https://preview-${{ github.event.pull_request.number }}.staging.com
182
+ --config playwright-vrt.config.json \
183
+ --verbose
180
184
 
181
- - uses: actions/upload-artifact@v4
185
+ - name: Upload VRT report
186
+ uses: actions/upload-artifact@v4
182
187
  if: always()
183
188
  with:
184
189
  name: vrt-report
@@ -204,5 +209,5 @@ All URLs and baseline snapshots are cached in `playwright-snapshots/` to minimiz
204
209
  ## Requirements
205
210
 
206
211
  - [Bun](https://bun.sh) runtime (for `bunx` command)
207
- - Or npm/yarn to install globally
208
212
  - Playwright `bunx playwright install chromium`
213
+ - NPM/Yarn and Node should also be supported.
package/dist/src/cli.js CHANGED
@@ -31,7 +31,7 @@ function isCacheValid(snapshotDir, config) {
31
31
  try {
32
32
  const stored = JSON.parse(fs.readFileSync(hashFile, 'utf-8'));
33
33
  const packageDir = path.join(__dirname, '..');
34
- const testFilePath = path.join(packageDir, 'tests', 'vrt.spec.ts');
34
+ const testFilePath = path.join(packageDir, 'tests', 'vrt.spec.js');
35
35
  const currentHashes = {
36
36
  config: computeConfigHash(config),
37
37
  testFile: fs.existsSync(testFilePath) ? computeFileHash(testFilePath) : '',
@@ -50,7 +50,7 @@ function isCacheValid(snapshotDir, config) {
50
50
  */
51
51
  function saveCacheHashes(snapshotDir, config) {
52
52
  const packageDir = path.join(__dirname, '..');
53
- const testFilePath = path.join(packageDir, 'tests', 'vrt.spec.ts');
53
+ const testFilePath = path.join(packageDir, 'tests', 'vrt.spec.js');
54
54
  const hashes = {
55
55
  config: computeConfigHash(config),
56
56
  testFile: fs.existsSync(testFilePath) ? computeFileHash(testFilePath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SAAS,CAAC,CAyBvE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmCtD"}
@@ -10,7 +10,6 @@ export const DEFAULT_CONFIG = {
10
10
  },
11
11
  viewports: [
12
12
  { name: 'desktop', width: 1920, height: 1080 },
13
- { name: 'mobile', width: 375, height: 667 },
14
13
  ],
15
14
  threshold: {
16
15
  maxDiffPixels: 100,
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";AAqCA,MAAM,CAAC,MAAM,cAAc,GAAuB;IAChD,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,CAAC,GAAG,CAAC;IACd,YAAY,EAAE;QACZ,QAAQ,EAAE,CAAC;QACX,mBAAmB,EAAE,IAAI;KAC1B;IACD,SAAS,EAAE;QACT,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAC9C,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;KAC5C;IACD,SAAS,EAAE;QACT,aAAa,EAAE,GAAG;QAClB,iBAAiB,EAAE,IAAI;KACxB;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB;IACjD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAEjC,sBAAsB;QACtB,OAAO;YACL,GAAG,cAAc;YACjB,GAAG,MAAM;YACT,YAAY,EAAE;gBACZ,GAAG,cAAc,CAAC,YAAY;gBAC9B,GAAG,MAAM,CAAC,YAAY;aACvB;YACD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,cAAc,CAAC,SAAS;YACv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,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,qBAAqB;IACrB,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,IAAI,MAAM,CAAC,SAAS,CAAC,iBAAiB;YAClC,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,iBAAiB,GAAG,CAAC,CAAC,EAAE,CAAC;YACvF,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iqual/playwright-vrt",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Standalone Visual Regression Testing CLI tool using Playwright",
5
5
  "type": "module",
6
6
  "bin": {