@vizzly-testing/cli 0.1.0 → 0.2.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 +2 -2
- package/docs/api-reference.md +603 -0
- package/docs/doctor-command.md +44 -0
- package/docs/getting-started.md +112 -0
- package/docs/tdd-mode.md +376 -0
- package/docs/test-integration.md +412 -0
- package/docs/upload-command.md +189 -0
- package/package.json +4 -6
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Getting Started with Vizzly CLI
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @vizzly-testing/cli
|
|
7
|
+
# or
|
|
8
|
+
npx @vizzly-testing/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Requirements
|
|
14
|
+
|
|
15
|
+
- Node.js 20 or newer
|
|
16
|
+
|
|
17
|
+
### 1. Initialize your project
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx vizzly init
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This creates a basic `vizzly.config.js` file with sensible defaults.
|
|
24
|
+
|
|
25
|
+
### 2. Set up your API token
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
export VIZZLY_TOKEN=your-api-token
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 3. Verify your setup
|
|
32
|
+
|
|
33
|
+
Run a fast local preflight:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx vizzly doctor
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Optionally, include API connectivity:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
VIZZLY_TOKEN=your-api-token npx vizzly doctor --api
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 4. Upload existing screenshots
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Upload a directory of screenshots
|
|
49
|
+
npx vizzly upload ./screenshots
|
|
50
|
+
|
|
51
|
+
# Upload with metadata
|
|
52
|
+
npx vizzly upload ./screenshots --build-name "Release v1.2.3"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 5. Integrate with your tests
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Run your test suite with Vizzly
|
|
59
|
+
npx vizzly run "npm test"
|
|
60
|
+
|
|
61
|
+
# Use TDD mode for local development
|
|
62
|
+
npx vizzly run "npm test" --tdd
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 6. In your test code
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
|
|
69
|
+
|
|
70
|
+
// Take a screenshot with your test framework
|
|
71
|
+
const screenshot = await page.screenshot();
|
|
72
|
+
|
|
73
|
+
// Send to Vizzly
|
|
74
|
+
await vizzlyScreenshot('homepage', screenshot, {
|
|
75
|
+
browser: 'chrome',
|
|
76
|
+
viewport: '1920x1080'
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 7. Check build status
|
|
81
|
+
|
|
82
|
+
After running tests or uploading screenshots, check your build status:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Check status of a specific build
|
|
86
|
+
npx vizzly status your-build-id
|
|
87
|
+
|
|
88
|
+
# Get detailed information
|
|
89
|
+
npx vizzly status your-build-id --verbose
|
|
90
|
+
|
|
91
|
+
# JSON output for automation
|
|
92
|
+
npx vizzly status your-build-id --json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The status command shows:
|
|
96
|
+
- Build progress and completion status
|
|
97
|
+
- Screenshot and comparison counts
|
|
98
|
+
- Direct link to view results in the web dashboard
|
|
99
|
+
- Git branch and commit information
|
|
100
|
+
- Timing and execution details
|
|
101
|
+
|
|
102
|
+
## Next Steps
|
|
103
|
+
|
|
104
|
+
- [Upload Command Guide](./upload-command.md)
|
|
105
|
+
- [Test Integration Guide](./test-integration.md)
|
|
106
|
+
- [TDD Mode Guide](./tdd-mode.md)
|
|
107
|
+
- [API Reference](./api-reference.md)
|
|
108
|
+
If you’re using a self-hosted or preview API, override the base URL:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
export VIZZLY_API_URL=https://your-api.example.com
|
|
112
|
+
```
|
package/docs/tdd-mode.md
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# TDD Mode Guide
|
|
2
|
+
|
|
3
|
+
TDD (Test-Driven Development) Mode enables fast local development by comparing screenshots locally without uploading to Vizzly. Perfect for rapid iteration and debugging visual changes.
|
|
4
|
+
|
|
5
|
+
## What is TDD Mode?
|
|
6
|
+
|
|
7
|
+
TDD Mode transforms your visual testing workflow by:
|
|
8
|
+
|
|
9
|
+
- **Local comparison** - Compares screenshots on your machine using `odiff`
|
|
10
|
+
- **Fast feedback** - No network uploads during development
|
|
11
|
+
- **Immediate results** - Tests fail instantly when visual differences are detected
|
|
12
|
+
- **Auto-baseline creation** - Creates baselines locally when none exist
|
|
13
|
+
- **No token required** - Works entirely offline for local development
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### 1. First Run (Creates Baseline)
|
|
18
|
+
|
|
19
|
+
Start TDD mode with any test - no setup required:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx vizzly tdd "npm test"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
🐻 **First run behavior:**
|
|
26
|
+
- Auto-detects missing API token (no `--allow-no-token` needed)
|
|
27
|
+
- Creates baseline from first screenshots
|
|
28
|
+
- Stores them in `.vizzly/baselines/`
|
|
29
|
+
- All tests pass (baseline creation)
|
|
30
|
+
|
|
31
|
+
### 2. Subsequent Runs (Compare Against Baseline)
|
|
32
|
+
|
|
33
|
+
Make changes and test again:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Make changes to your UI
|
|
37
|
+
vim src/components/Header.js
|
|
38
|
+
|
|
39
|
+
# Test immediately with local comparison
|
|
40
|
+
npx vizzly tdd "npm test"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
🐻 **Comparison behavior:**
|
|
44
|
+
- Compares new screenshots against local baselines
|
|
45
|
+
- **Tests fail immediately** when visual differences detected
|
|
46
|
+
- Shows exact diff paths and percentages
|
|
47
|
+
- Creates diff images in `.vizzly/diffs/`
|
|
48
|
+
|
|
49
|
+
### 3. Accept Changes (Update Baseline)
|
|
50
|
+
|
|
51
|
+
When you're happy with changes, accept them as new baselines:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx vizzly tdd "npm test" --set-baseline
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
🐻 **Baseline update behavior:**
|
|
58
|
+
- Skips all comparisons
|
|
59
|
+
- Sets current screenshots as new baselines
|
|
60
|
+
- All tests pass (baseline accepted)
|
|
61
|
+
- Future runs use updated baselines
|
|
62
|
+
|
|
63
|
+
### 4. Upload When Ready (Optional)
|
|
64
|
+
|
|
65
|
+
When you're satisfied with changes, upload to Vizzly:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx vizzly run "npm test" --wait
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## How It Works
|
|
72
|
+
|
|
73
|
+
TDD Mode creates a local development environment:
|
|
74
|
+
|
|
75
|
+
1. **Downloads baselines** - Gets approved screenshots from Vizzly
|
|
76
|
+
2. **Runs tests** - Executes your test suite normally
|
|
77
|
+
3. **Captures screenshots** - Collects new screenshots via `vizzlyScreenshot()`
|
|
78
|
+
4. **Compares locally** - Uses `odiff` for pixel-perfect comparison
|
|
79
|
+
5. **Fails immediately** - Tests fail when differences exceed threshold
|
|
80
|
+
6. **Saves comparisons** - Stores diff images for inspection
|
|
81
|
+
|
|
82
|
+
## Directory Structure
|
|
83
|
+
|
|
84
|
+
TDD Mode creates a `.vizzly/` directory:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
.vizzly/
|
|
88
|
+
├── baselines/ # Baseline images (local or downloaded)
|
|
89
|
+
│ ├── homepage.png
|
|
90
|
+
│ ├── dashboard.png
|
|
91
|
+
│ └── metadata.json # Baseline build information
|
|
92
|
+
├── current/ # Current test screenshots
|
|
93
|
+
│ ├── homepage.png
|
|
94
|
+
│ └── dashboard.png
|
|
95
|
+
└── diffs/ # Visual diff images (when differences found)
|
|
96
|
+
├── homepage.png # Red overlay showing differences
|
|
97
|
+
└── dashboard.png
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Important**: Add `.vizzly/` to your `.gitignore` file as it contains local development artifacts.
|
|
101
|
+
|
|
102
|
+
## Command Options
|
|
103
|
+
|
|
104
|
+
### Basic TDD Mode
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
vizzly tdd "npm test"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Accept Changes (Update Baseline)
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
vizzly tdd "npm test" --set-baseline
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
🐻 Use this when you want to accept current screenshots as the new baseline.
|
|
117
|
+
|
|
118
|
+
### Custom Baseline Source (With API Token)
|
|
119
|
+
|
|
120
|
+
**`--baseline-build <id>`** - Use specific build as baseline
|
|
121
|
+
```bash
|
|
122
|
+
VIZZLY_TOKEN=your-token vizzly tdd "npm test" --baseline-build build-abc123
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**`--baseline-comparison <id>`** - Use specific comparison as baseline
|
|
126
|
+
```bash
|
|
127
|
+
VIZZLY_TOKEN=your-token vizzly tdd "npm test" --baseline-comparison comparison-xyz789
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Server Configuration
|
|
131
|
+
|
|
132
|
+
TDD Mode runs a local server for screenshot capture:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
vizzly tdd "npm test" --port 3002
|
|
136
|
+
vizzly tdd "npm test" --timeout 60000
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Development Workflow
|
|
140
|
+
|
|
141
|
+
### Initial Development
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# 1. Create initial baselines
|
|
145
|
+
npx vizzly run "npm test" --wait
|
|
146
|
+
|
|
147
|
+
# 2. Start TDD development
|
|
148
|
+
npx vizzly run "npm test" --tdd
|
|
149
|
+
|
|
150
|
+
# 3. Make changes and iterate
|
|
151
|
+
# Edit code...
|
|
152
|
+
npx vizzly run "npm test" --tdd
|
|
153
|
+
|
|
154
|
+
# 4. Upload when satisfied
|
|
155
|
+
npx vizzly run "npm test" --wait
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Feature Development
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Start with latest baselines
|
|
162
|
+
npx vizzly run "npm test" --tdd
|
|
163
|
+
|
|
164
|
+
# Develop new feature with immediate feedback
|
|
165
|
+
while [ $? -ne 0 ]; do
|
|
166
|
+
# Edit code to fix visual differences
|
|
167
|
+
vim src/components/NewFeature.js
|
|
168
|
+
npx vizzly run "npm test" --tdd
|
|
169
|
+
done
|
|
170
|
+
|
|
171
|
+
# Upload completed feature
|
|
172
|
+
npx vizzly run "npm test" --build-name "Feature: New Dashboard"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Bug Fixing
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Use TDD mode to verify fixes
|
|
179
|
+
npx vizzly run "npm test" --tdd
|
|
180
|
+
|
|
181
|
+
# Tests should pass when bug is fixed
|
|
182
|
+
# Then upload the fix
|
|
183
|
+
npx vizzly run "npm test" --build-name "Fix: Header alignment issue"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Comparison Settings
|
|
187
|
+
|
|
188
|
+
TDD Mode uses the same comparison settings as production:
|
|
189
|
+
|
|
190
|
+
- **Threshold matching** - Uses your configured threshold
|
|
191
|
+
- **Anti-aliasing detection** - Handles font rendering differences
|
|
192
|
+
- **Color tolerance** - Accounts for minor color variations
|
|
193
|
+
|
|
194
|
+
Configure in `vizzly.config.js`:
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
export default {
|
|
198
|
+
comparison: {
|
|
199
|
+
threshold: 0.01, // 1% difference tolerance
|
|
200
|
+
ignoreAntialiasing: true,
|
|
201
|
+
ignoreColors: false
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Managing Baselines
|
|
207
|
+
|
|
208
|
+
### Check Current Baseline Status
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npx vizzly status # Shows latest build info
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Update Baselines
|
|
215
|
+
|
|
216
|
+
Download new baselines from a different build:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npx vizzly run "npm test" --tdd --baseline-build build-xyz789
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Force Baseline Refresh
|
|
223
|
+
|
|
224
|
+
Delete local baselines to force re-download:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
rm -rf .vizzly/baselines/
|
|
228
|
+
npx vizzly run "npm test" --tdd
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Advanced Usage
|
|
232
|
+
|
|
233
|
+
### Conditional TDD Mode
|
|
234
|
+
|
|
235
|
+
Check if TDD mode is active in your tests:
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
import { getVizzlyInfo } from '@vizzly-testing/cli/client';
|
|
239
|
+
|
|
240
|
+
const info = getVizzlyInfo();
|
|
241
|
+
if (info.tddMode) {
|
|
242
|
+
console.log('Running in TDD mode - fast local comparison');
|
|
243
|
+
} else {
|
|
244
|
+
console.log('Running in upload mode - results going to Vizzly');
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Custom Comparison Logic
|
|
249
|
+
|
|
250
|
+
TDD mode respects your screenshot properties:
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
await vizzlyScreenshot('homepage', screenshot, {
|
|
254
|
+
threshold: 0.05, // More tolerant for this specific screenshot
|
|
255
|
+
browser: 'chrome',
|
|
256
|
+
viewport: '1920x1080'
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## CI/CD Integration
|
|
261
|
+
|
|
262
|
+
Use TDD mode for faster PR builds:
|
|
263
|
+
|
|
264
|
+
```yaml
|
|
265
|
+
name: Visual Tests
|
|
266
|
+
on: [push, pull_request]
|
|
267
|
+
|
|
268
|
+
jobs:
|
|
269
|
+
visual-tests:
|
|
270
|
+
runs-on: ubuntu-latest
|
|
271
|
+
steps:
|
|
272
|
+
- uses: actions/checkout@v4
|
|
273
|
+
- uses: actions/setup-node@v4
|
|
274
|
+
- run: npm ci
|
|
275
|
+
|
|
276
|
+
# Use TDD mode for PR builds (faster, no uploads)
|
|
277
|
+
- name: TDD Visual Tests (PR)
|
|
278
|
+
if: github.event_name == 'pull_request'
|
|
279
|
+
run: npx vizzly run "npm test" --tdd
|
|
280
|
+
env:
|
|
281
|
+
VIZZLY_TOKEN: ${{ secrets.VIZZLY_TOKEN }}
|
|
282
|
+
|
|
283
|
+
# Upload full build for main branch
|
|
284
|
+
- name: Full Visual Tests (main)
|
|
285
|
+
if: github.ref == 'refs/heads/main'
|
|
286
|
+
run: npx vizzly run "npm test" --wait
|
|
287
|
+
env:
|
|
288
|
+
VIZZLY_TOKEN: ${{ secrets.VIZZLY_TOKEN }}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Benefits
|
|
292
|
+
|
|
293
|
+
### Speed
|
|
294
|
+
- **No network uploads** - Everything happens locally
|
|
295
|
+
- **Immediate feedback** - See results in seconds
|
|
296
|
+
- **No API rate limits** - Test as often as needed
|
|
297
|
+
|
|
298
|
+
### Development Experience
|
|
299
|
+
- **Fast iteration** - Make changes and test immediately
|
|
300
|
+
- **Visual debugging** - See exact pixel differences
|
|
301
|
+
- **Offline capable** - Works without internet (after initial baseline download)
|
|
302
|
+
|
|
303
|
+
### Cost Efficiency
|
|
304
|
+
- **Reduced API usage** - Only upload final results
|
|
305
|
+
- **Faster CI builds** - Use TDD mode for PR validation
|
|
306
|
+
- **Local development** - No cloud resources consumed
|
|
307
|
+
|
|
308
|
+
## Troubleshooting
|
|
309
|
+
|
|
310
|
+
### No Baseline Found
|
|
311
|
+
```
|
|
312
|
+
Error: No baseline found for screenshot 'homepage'
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Solution**: Run a successful build first to create baselines:
|
|
316
|
+
```bash
|
|
317
|
+
npx vizzly run "npm test" --wait
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Visual Difference Detected
|
|
321
|
+
```
|
|
322
|
+
Error: Visual difference detected in 'homepage' (threshold: 1.5%)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
This is expected behavior! Check the comparison image:
|
|
326
|
+
```bash
|
|
327
|
+
open .vizzly/comparisons/homepage.png
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Fix the visual issue or update your baseline if the change is intentional.
|
|
331
|
+
|
|
332
|
+
### Comparison Failed
|
|
333
|
+
```
|
|
334
|
+
Error: Failed to compare 'homepage': baseline image not found
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Solution**: Refresh baselines:
|
|
338
|
+
```bash
|
|
339
|
+
rm -rf .vizzly/baselines/
|
|
340
|
+
npx vizzly run "npm test" --tdd
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Odiff Not Found
|
|
344
|
+
```
|
|
345
|
+
Error: odiff binary not found
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**Solution**: The `odiff-bin` package should be installed automatically. Try:
|
|
349
|
+
```bash
|
|
350
|
+
npm install odiff-bin
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Best Practices
|
|
354
|
+
|
|
355
|
+
### Use TDD Mode For
|
|
356
|
+
- **Local development** - Fast iteration on UI changes
|
|
357
|
+
- **Bug fixing** - Verify visual fixes immediately
|
|
358
|
+
- **PR validation** - Quick checks without uploading
|
|
359
|
+
- **Debugging** - Understand exactly what changed visually
|
|
360
|
+
|
|
361
|
+
### Use Upload Mode For
|
|
362
|
+
- **Final results** - When changes are ready for review
|
|
363
|
+
- **Baseline creation** - Initial setup and approved changes
|
|
364
|
+
- **Production releases** - Official visual regression testing
|
|
365
|
+
- **Team collaboration** - Sharing results with designers/stakeholders
|
|
366
|
+
|
|
367
|
+
### Directory Management
|
|
368
|
+
- **Add to .gitignore** - Never commit `.vizzly/` directory
|
|
369
|
+
- **Regular cleanup** - Delete old comparison images periodically
|
|
370
|
+
- **Baseline updates** - Refresh baselines when UI intentionally changes
|
|
371
|
+
|
|
372
|
+
## Next Steps
|
|
373
|
+
|
|
374
|
+
- 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
|