@vizzly-testing/cli 0.4.0 → 0.6.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/README.md +35 -5
- package/dist/cli.js +17 -1
- package/dist/commands/run.js +62 -21
- package/dist/commands/tdd.js +35 -35
- package/dist/commands/upload.js +4 -2
- package/dist/server/handlers/tdd-handler.js +82 -8
- package/dist/services/html-report-generator.js +377 -0
- package/dist/services/report-generator/report.css +355 -0
- package/dist/services/report-generator/viewer.js +100 -0
- package/dist/services/server-manager.js +3 -2
- package/dist/services/tdd-service.js +375 -66
- package/dist/services/test-runner.js +64 -35
- package/dist/services/uploader.js +5 -3
- package/dist/types/commands/tdd.d.ts +3 -2
- package/dist/types/server/handlers/tdd-handler.d.ts +18 -1
- package/dist/types/services/html-report-generator.d.ts +52 -0
- package/dist/types/services/report-generator/viewer.d.ts +0 -0
- package/dist/types/services/server-manager.d.ts +19 -1
- package/dist/types/services/tdd-service.d.ts +24 -3
- package/dist/types/services/uploader.d.ts +2 -1
- package/dist/types/utils/ci-env.d.ts +55 -0
- package/dist/types/utils/config-loader.d.ts +3 -0
- package/dist/types/utils/git.d.ts +12 -0
- package/dist/types/utils/security.d.ts +29 -0
- package/dist/utils/ci-env.js +293 -0
- package/dist/utils/config-loader.js +7 -0
- package/dist/utils/git.js +38 -0
- package/dist/utils/security.js +154 -0
- package/docs/api-reference.md +15 -0
- package/docs/tdd-mode.md +58 -12
- package/docs/test-integration.md +6 -0
- package/package.json +6 -6
package/docs/tdd-mode.md
CHANGED
|
@@ -8,7 +8,7 @@ TDD Mode transforms your visual testing workflow by:
|
|
|
8
8
|
|
|
9
9
|
- **Local comparison** - Compares screenshots on your machine using `odiff`
|
|
10
10
|
- **Fast feedback** - No network uploads during development
|
|
11
|
-
- **Immediate results** - Tests fail instantly when visual differences are detected
|
|
11
|
+
- **Immediate results** - Tests fail instantly when visual differences are detected
|
|
12
12
|
- **Auto-baseline creation** - Creates baselines locally when none exist
|
|
13
13
|
- **No token required** - Works entirely offline for local development
|
|
14
14
|
|
|
@@ -43,7 +43,7 @@ npx vizzly tdd "npm test"
|
|
|
43
43
|
🐻 **Comparison behavior:**
|
|
44
44
|
- Compares new screenshots against local baselines
|
|
45
45
|
- **Tests fail immediately** when visual differences detected
|
|
46
|
-
-
|
|
46
|
+
- Generates interactive HTML report for visual analysis
|
|
47
47
|
- Creates diff images in `.vizzly/diffs/`
|
|
48
48
|
|
|
49
49
|
### 3. Accept Changes (Update Baseline)
|
|
@@ -56,7 +56,7 @@ npx vizzly tdd "npm test" --set-baseline
|
|
|
56
56
|
|
|
57
57
|
🐻 **Baseline update behavior:**
|
|
58
58
|
- Skips all comparisons
|
|
59
|
-
- Sets current screenshots as new baselines
|
|
59
|
+
- Sets current screenshots as new baselines
|
|
60
60
|
- All tests pass (baseline accepted)
|
|
61
61
|
- Future runs use updated baselines
|
|
62
62
|
|
|
@@ -73,7 +73,7 @@ npx vizzly run "npm test" --wait
|
|
|
73
73
|
TDD Mode creates a local development environment:
|
|
74
74
|
|
|
75
75
|
1. **Downloads baselines** - Gets approved screenshots from Vizzly
|
|
76
|
-
2. **Runs tests** - Executes your test suite normally
|
|
76
|
+
2. **Runs tests** - Executes your test suite normally
|
|
77
77
|
3. **Captures screenshots** - Collects new screenshots via `vizzlyScreenshot()`
|
|
78
78
|
4. **Compares locally** - Uses `odiff` for pixel-perfect comparison
|
|
79
79
|
5. **Fails immediately** - Tests fail when differences exceed threshold
|
|
@@ -89,9 +89,11 @@ TDD Mode creates a `.vizzly/` directory:
|
|
|
89
89
|
│ ├── homepage.png
|
|
90
90
|
│ ├── dashboard.png
|
|
91
91
|
│ └── metadata.json # Baseline build information
|
|
92
|
-
├── current/ # Current test screenshots
|
|
92
|
+
├── current/ # Current test screenshots
|
|
93
93
|
│ ├── homepage.png
|
|
94
94
|
│ └── dashboard.png
|
|
95
|
+
├── report/ # Interactive HTML report
|
|
96
|
+
│ └── index.html # Visual comparison interface
|
|
95
97
|
└── diffs/ # Visual diff images (when differences found)
|
|
96
98
|
├── homepage.png # Red overlay showing differences
|
|
97
99
|
└── dashboard.png
|
|
@@ -99,6 +101,50 @@ TDD Mode creates a `.vizzly/` directory:
|
|
|
99
101
|
|
|
100
102
|
**Important**: Add `.vizzly/` to your `.gitignore` file as it contains local development artifacts.
|
|
101
103
|
|
|
104
|
+
## Interactive HTML Report
|
|
105
|
+
|
|
106
|
+
Each TDD run automatically generates a comprehensive HTML report at `.vizzly/report/index.html`. This report provides advanced visual comparison tools to analyze differences:
|
|
107
|
+
|
|
108
|
+
### 🐻 **Viewing Modes**
|
|
109
|
+
|
|
110
|
+
**Overlay Mode** (Default)
|
|
111
|
+
- Shows current screenshot as base layer
|
|
112
|
+
- Click to toggle diff overlay on/off
|
|
113
|
+
- Perfect for spotting subtle changes
|
|
114
|
+
|
|
115
|
+
**Side-by-Side Mode**
|
|
116
|
+
- Displays baseline and current screenshots horizontally
|
|
117
|
+
- Easy to compare layout and content changes
|
|
118
|
+
- Great for reviewing larger modifications
|
|
119
|
+
|
|
120
|
+
**Onion Skin Mode**
|
|
121
|
+
- Drag across image to reveal baseline underneath
|
|
122
|
+
- Interactive reveal lets you control comparison area
|
|
123
|
+
- Ideal for precise change inspection
|
|
124
|
+
|
|
125
|
+
**Toggle Mode**
|
|
126
|
+
- Click image to switch between baseline and current
|
|
127
|
+
- Quick back-and-forth comparison
|
|
128
|
+
- Simple way to see before/after
|
|
129
|
+
|
|
130
|
+
### 🐻 **Report Features**
|
|
131
|
+
|
|
132
|
+
- **Dark Theme** - Easy on the eyes during long debugging sessions
|
|
133
|
+
- **Mobile Responsive** - Works on any screen size
|
|
134
|
+
- **Clickable File Paths** - Click from terminal to open instantly
|
|
135
|
+
- **Clean Status Display** - Shows "Visual differences detected" instead of technical metrics
|
|
136
|
+
- **Test Summary** - Total, passed, failed counts and pass rate
|
|
137
|
+
|
|
138
|
+
### 🐻 **Opening the Report**
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Report path is shown after each run
|
|
142
|
+
🐻 View detailed report: file:///path/to/.vizzly/report/index.html
|
|
143
|
+
|
|
144
|
+
# Click the link in your terminal, or open manually
|
|
145
|
+
open .vizzly/report/index.html # macOS
|
|
146
|
+
```
|
|
147
|
+
|
|
102
148
|
## Command Options
|
|
103
149
|
|
|
104
150
|
### Basic TDD Mode
|
|
@@ -122,7 +168,7 @@ vizzly tdd "npm test" --set-baseline
|
|
|
122
168
|
VIZZLY_TOKEN=your-token vizzly tdd "npm test" --baseline-build build-abc123
|
|
123
169
|
```
|
|
124
170
|
|
|
125
|
-
**`--baseline-comparison <id>`** - Use specific comparison as baseline
|
|
171
|
+
**`--baseline-comparison <id>`** - Use specific comparison as baseline
|
|
126
172
|
```bash
|
|
127
173
|
VIZZLY_TOKEN=your-token vizzly tdd "npm test" --baseline-comparison comparison-xyz789
|
|
128
174
|
```
|
|
@@ -272,14 +318,14 @@ jobs:
|
|
|
272
318
|
- uses: actions/checkout@v4
|
|
273
319
|
- uses: actions/setup-node@v4
|
|
274
320
|
- run: npm ci
|
|
275
|
-
|
|
321
|
+
|
|
276
322
|
# Use TDD mode for PR builds (faster, no uploads)
|
|
277
323
|
- name: TDD Visual Tests (PR)
|
|
278
324
|
if: github.event_name == 'pull_request'
|
|
279
325
|
run: npx vizzly tdd "npm test"
|
|
280
326
|
env:
|
|
281
327
|
VIZZLY_TOKEN: ${{ secrets.VIZZLY_TOKEN }}
|
|
282
|
-
|
|
328
|
+
|
|
283
329
|
# Upload full build for main branch
|
|
284
330
|
- name: Full Visual Tests (main)
|
|
285
331
|
if: github.ref == 'refs/heads/main'
|
|
@@ -295,7 +341,7 @@ jobs:
|
|
|
295
341
|
- **Immediate feedback** - See results in seconds
|
|
296
342
|
- **No API rate limits** - Test as often as needed
|
|
297
343
|
|
|
298
|
-
### Development Experience
|
|
344
|
+
### Development Experience
|
|
299
345
|
- **Fast iteration** - Make changes and test immediately
|
|
300
346
|
- **Visual debugging** - See exact pixel differences
|
|
301
347
|
- **Offline capable** - Works without internet (after initial baseline download)
|
|
@@ -354,7 +400,7 @@ npm install odiff-bin
|
|
|
354
400
|
|
|
355
401
|
### Use TDD Mode For
|
|
356
402
|
- **Local development** - Fast iteration on UI changes
|
|
357
|
-
- **Bug fixing** - Verify visual fixes immediately
|
|
403
|
+
- **Bug fixing** - Verify visual fixes immediately
|
|
358
404
|
- **PR validation** - Quick checks without uploading
|
|
359
405
|
- **Debugging** - Understand exactly what changed visually
|
|
360
406
|
|
|
@@ -372,5 +418,5 @@ npm install odiff-bin
|
|
|
372
418
|
## Next Steps
|
|
373
419
|
|
|
374
420
|
- Learn about [Test Integration](./test-integration.md) for screenshot capture
|
|
375
|
-
- Explore [Upload Command](./upload-command.md) for direct uploads
|
|
376
|
-
- Check the [API Reference](./api-reference.md) for programmatic usage
|
|
421
|
+
- Explore [Upload Command](./upload-command.md) for direct uploads
|
|
422
|
+
- Check the [API Reference](./api-reference.md) for programmatic usage
|
package/docs/test-integration.md
CHANGED
|
@@ -275,8 +275,14 @@ jobs:
|
|
|
275
275
|
- run: npx vizzly run "npm test" --wait
|
|
276
276
|
env:
|
|
277
277
|
VIZZLY_TOKEN: ${{ secrets.VIZZLY_TOKEN }}
|
|
278
|
+
# Optional: Enhanced git information from GitHub context
|
|
279
|
+
VIZZLY_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
|
280
|
+
VIZZLY_COMMIT_SHA: ${{ github.event.head_commit.id }}
|
|
281
|
+
VIZZLY_BRANCH: ${{ github.head_ref || github.ref_name }}
|
|
278
282
|
```
|
|
279
283
|
|
|
284
|
+
**Enhanced Git Information:** The `VIZZLY_*` environment variables ensure accurate git metadata is captured in your builds, avoiding issues with merge commits that can occur in CI environments.
|
|
285
|
+
|
|
280
286
|
### GitLab CI
|
|
281
287
|
|
|
282
288
|
```yaml
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizzly-testing/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Visual review platform for UI developers and designers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visual-testing",
|
|
@@ -53,9 +53,10 @@
|
|
|
53
53
|
],
|
|
54
54
|
"scripts": {
|
|
55
55
|
"start": "node src/index.js",
|
|
56
|
-
"build": "npm run clean && npm run compile && npm run types",
|
|
56
|
+
"build": "npm run clean && npm run compile && npm run copy-assets && npm run types",
|
|
57
57
|
"clean": "rimraf dist",
|
|
58
58
|
"compile": "babel src --out-dir dist --ignore '**/*.test.js'",
|
|
59
|
+
"copy-assets": "cp src/services/report-generator/report.css dist/services/report-generator/",
|
|
59
60
|
"types": "tsc --emitDeclarationOnly --outDir dist/types",
|
|
60
61
|
"prepublishOnly": "npm test && npm run build",
|
|
61
62
|
"test": "vitest run",
|
|
@@ -73,11 +74,11 @@
|
|
|
73
74
|
"registry": "https://registry.npmjs.org/"
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
|
-
"commander": "^
|
|
77
|
+
"commander": "^14.0.0",
|
|
77
78
|
"cosmiconfig": "^9.0.0",
|
|
78
79
|
"dotenv": "^17.2.1",
|
|
79
80
|
"form-data": "^4.0.0",
|
|
80
|
-
"glob": "^
|
|
81
|
+
"glob": "^11.0.3",
|
|
81
82
|
"odiff-bin": "^3.2.1"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
@@ -93,8 +94,7 @@
|
|
|
93
94
|
"eslint-config-prettier": "^10.1.8",
|
|
94
95
|
"eslint-plugin-prettier": "^5.5.3",
|
|
95
96
|
"prettier": "^3.6.2",
|
|
96
|
-
"
|
|
97
|
-
"rimraf": "^5.0.5",
|
|
97
|
+
"rimraf": "^6.0.1",
|
|
98
98
|
"typescript": "^5.0.4",
|
|
99
99
|
"vite": "^7.1.2",
|
|
100
100
|
"vitest": "^3.2.4"
|