@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
package/README.md
CHANGED
|
@@ -331,7 +331,7 @@ We welcome contributions! Whether you're fixing bugs, adding features, or improv
|
|
|
331
331
|
|
|
332
332
|
### Getting Started
|
|
333
333
|
|
|
334
|
-
1. Fork the repository on [GitHub](https://github.com/vizzly/cli)
|
|
334
|
+
1. Fork the repository on [GitHub](https://github.com/vizzly-testing/cli)
|
|
335
335
|
2. Clone your fork locally: `git clone https://github.com/your-username/cli.git`
|
|
336
336
|
3. Install dependencies: `npm install`
|
|
337
337
|
4. Run tests to ensure everything works: `npm test`
|
|
@@ -348,7 +348,7 @@ We welcome contributions! Whether you're fixing bugs, adding features, or improv
|
|
|
348
348
|
|
|
349
349
|
### Reporting Issues
|
|
350
350
|
|
|
351
|
-
Found a bug or have a feature request? Please [open an issue](https://github.com/vizzly/cli/issues) with:
|
|
351
|
+
Found a bug or have a feature request? Please [open an issue](https://github.com/vizzly-testing/cli/issues) with:
|
|
352
352
|
|
|
353
353
|
- A clear description of the problem or request
|
|
354
354
|
- Steps to reproduce (for bugs)
|
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
This document provides comprehensive reference for all Vizzly CLI APIs, including the client library, SDK, and command-line interface.
|
|
4
|
+
|
|
5
|
+
## Client API (`@vizzly-testing/cli/client`)
|
|
6
|
+
|
|
7
|
+
The client API is a lightweight library for capturing screenshots in your tests.
|
|
8
|
+
|
|
9
|
+
### `vizzlyScreenshot(name, imageBuffer, options)`
|
|
10
|
+
|
|
11
|
+
Capture a screenshot for visual regression testing.
|
|
12
|
+
|
|
13
|
+
**Parameters:**
|
|
14
|
+
- `name` (string) - Unique screenshot identifier
|
|
15
|
+
- `imageBuffer` (Buffer) - PNG image data as Buffer
|
|
16
|
+
- `options` (object, optional) - Configuration and metadata
|
|
17
|
+
|
|
18
|
+
**Options:**
|
|
19
|
+
```javascript
|
|
20
|
+
{
|
|
21
|
+
// Comparison settings
|
|
22
|
+
threshold: 0.01, // Pixel difference threshold (0-1)
|
|
23
|
+
|
|
24
|
+
// Metadata for organization (all optional)
|
|
25
|
+
properties: {
|
|
26
|
+
browser: 'chrome', // Browser name
|
|
27
|
+
viewport: '1920x1080', // Viewport size
|
|
28
|
+
device: 'desktop', // Device type
|
|
29
|
+
component: 'header', // UI component name
|
|
30
|
+
page: 'home', // Page identifier
|
|
31
|
+
theme: 'dark', // Theme/variant
|
|
32
|
+
userType: 'admin', // User context
|
|
33
|
+
state: 'logged-in', // Application state
|
|
34
|
+
environment: 'staging', // Environment
|
|
35
|
+
// ... any custom metadata
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Returns:** `Promise<void>`
|
|
41
|
+
|
|
42
|
+
**Example:**
|
|
43
|
+
```javascript
|
|
44
|
+
import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
|
|
45
|
+
|
|
46
|
+
const screenshot = await page.screenshot();
|
|
47
|
+
await vizzlyScreenshot('homepage', screenshot, {
|
|
48
|
+
threshold: 0.02,
|
|
49
|
+
properties: {
|
|
50
|
+
browser: 'chrome',
|
|
51
|
+
viewport: '1920x1080',
|
|
52
|
+
component: 'hero-section'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `vizzlyFlush()`
|
|
58
|
+
|
|
59
|
+
Wait for all queued screenshots to be processed.
|
|
60
|
+
|
|
61
|
+
**Returns:** `Promise<void>`
|
|
62
|
+
|
|
63
|
+
**Example:**
|
|
64
|
+
```javascript
|
|
65
|
+
import { vizzlyFlush } from '@vizzly-testing/cli/client';
|
|
66
|
+
|
|
67
|
+
// Take multiple screenshots
|
|
68
|
+
await vizzlyScreenshot('page1', screenshot1);
|
|
69
|
+
await vizzlyScreenshot('page2', screenshot2);
|
|
70
|
+
|
|
71
|
+
// Wait for all to be processed
|
|
72
|
+
await vizzlyFlush();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `isVizzlyEnabled()`
|
|
76
|
+
|
|
77
|
+
Check if Vizzly screenshot capture is currently enabled.
|
|
78
|
+
|
|
79
|
+
**Returns:** `boolean`
|
|
80
|
+
|
|
81
|
+
**Example:**
|
|
82
|
+
```javascript
|
|
83
|
+
import { isVizzlyEnabled } from '@vizzly-testing/cli/client';
|
|
84
|
+
|
|
85
|
+
if (isVizzlyEnabled()) {
|
|
86
|
+
const screenshot = await page.screenshot();
|
|
87
|
+
await vizzlyScreenshot('conditional-screenshot', screenshot);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### `getVizzlyInfo()`
|
|
92
|
+
|
|
93
|
+
Get current Vizzly environment information and settings.
|
|
94
|
+
|
|
95
|
+
**Returns:** `object`
|
|
96
|
+
```javascript
|
|
97
|
+
{
|
|
98
|
+
enabled: boolean, // Whether Vizzly is active
|
|
99
|
+
serverUrl: string, // Local server URL
|
|
100
|
+
buildId: string, // Current build ID
|
|
101
|
+
tddMode: boolean, // Whether TDD mode is active
|
|
102
|
+
version: string // Client version
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Example:**
|
|
107
|
+
```javascript
|
|
108
|
+
import { getVizzlyInfo } from '@vizzly-testing/cli/client';
|
|
109
|
+
|
|
110
|
+
const info = getVizzlyInfo();
|
|
111
|
+
console.log(`Vizzly ${info.enabled ? 'enabled' : 'disabled'}`);
|
|
112
|
+
console.log(`TDD Mode: ${info.tddMode}`);
|
|
113
|
+
console.log(`Build ID: ${info.buildId}`);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### `configure(config)`
|
|
117
|
+
|
|
118
|
+
Configure client settings (advanced usage).
|
|
119
|
+
|
|
120
|
+
**Parameters:**
|
|
121
|
+
- `config` (object) - Configuration options
|
|
122
|
+
|
|
123
|
+
**Config Options:**
|
|
124
|
+
```javascript
|
|
125
|
+
{
|
|
126
|
+
serverUrl: string, // Override server URL
|
|
127
|
+
enabled: boolean, // Enable/disable capture
|
|
128
|
+
timeout: number, // Request timeout (ms)
|
|
129
|
+
retries: number // Number of retry attempts
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Example:**
|
|
134
|
+
```javascript
|
|
135
|
+
import { configure } from '@vizzly-testing/cli/client';
|
|
136
|
+
|
|
137
|
+
configure({
|
|
138
|
+
serverUrl: 'http://localhost:3001',
|
|
139
|
+
enabled: true,
|
|
140
|
+
timeout: 10000
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### `setEnabled(enabled)`
|
|
145
|
+
|
|
146
|
+
Enable or disable screenshot capture.
|
|
147
|
+
|
|
148
|
+
**Parameters:**
|
|
149
|
+
- `enabled` (boolean) - Whether to enable capture
|
|
150
|
+
|
|
151
|
+
**Example:**
|
|
152
|
+
```javascript
|
|
153
|
+
import { setEnabled } from '@vizzly-testing/cli/client';
|
|
154
|
+
|
|
155
|
+
// Disable screenshots for this test
|
|
156
|
+
setEnabled(false);
|
|
157
|
+
await runTest();
|
|
158
|
+
|
|
159
|
+
// Re-enable
|
|
160
|
+
setEnabled(true);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## SDK API (`@vizzly-testing/cli/sdk`)
|
|
164
|
+
|
|
165
|
+
The SDK provides comprehensive programmatic access to Vizzly functionality.
|
|
166
|
+
|
|
167
|
+
### `createVizzly(config, options)`
|
|
168
|
+
|
|
169
|
+
Create a new Vizzly SDK instance.
|
|
170
|
+
|
|
171
|
+
**Parameters:**
|
|
172
|
+
- `config` (object) - Vizzly configuration
|
|
173
|
+
- `options` (object, optional) - SDK options
|
|
174
|
+
|
|
175
|
+
**Returns:** `VizzlySDK` instance
|
|
176
|
+
|
|
177
|
+
**Example:**
|
|
178
|
+
```javascript
|
|
179
|
+
import { createVizzly } from '@vizzly-testing/cli/sdk';
|
|
180
|
+
|
|
181
|
+
const vizzly = createVizzly({
|
|
182
|
+
apiKey: process.env.VIZZLY_TOKEN,
|
|
183
|
+
project: 'my-project'
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### `VizzlySDK` Class
|
|
188
|
+
|
|
189
|
+
The main SDK class that extends `EventEmitter`.
|
|
190
|
+
|
|
191
|
+
#### Methods
|
|
192
|
+
|
|
193
|
+
##### `start()`
|
|
194
|
+
Start the Vizzly server and initialize the SDK.
|
|
195
|
+
|
|
196
|
+
**Returns:** `Promise<void>`
|
|
197
|
+
|
|
198
|
+
##### `stop()`
|
|
199
|
+
Stop the Vizzly server and cleanup resources.
|
|
200
|
+
|
|
201
|
+
**Returns:** `Promise<void>`
|
|
202
|
+
|
|
203
|
+
##### `screenshot(name, imageBuffer, options)`
|
|
204
|
+
Capture a screenshot (same as client API).
|
|
205
|
+
|
|
206
|
+
**Returns:** `Promise<void>`
|
|
207
|
+
|
|
208
|
+
##### `upload(options)`
|
|
209
|
+
Upload screenshots to Vizzly.
|
|
210
|
+
|
|
211
|
+
**Parameters:**
|
|
212
|
+
- `options` (object) - Upload configuration
|
|
213
|
+
|
|
214
|
+
**Options:**
|
|
215
|
+
```javascript
|
|
216
|
+
{
|
|
217
|
+
screenshotsDir: string, // Directory containing screenshots
|
|
218
|
+
buildName: string, // Build name
|
|
219
|
+
environment: string, // Environment name
|
|
220
|
+
wait: boolean // Wait for completion
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
##### `compare(name, imageBuffer)`
|
|
225
|
+
Run local comparison (TDD mode).
|
|
226
|
+
|
|
227
|
+
**Returns:** `Promise<ComparisonResult>`
|
|
228
|
+
|
|
229
|
+
##### `getConfig()`
|
|
230
|
+
Get current SDK configuration.
|
|
231
|
+
|
|
232
|
+
**Returns:** `object` - Current configuration
|
|
233
|
+
|
|
234
|
+
#### Events
|
|
235
|
+
|
|
236
|
+
The SDK emits various events for monitoring:
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
vizzly.on('server:started', (port) => {
|
|
240
|
+
console.log(`Server started on port ${port}`);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
vizzly.on('server:stopped', () => {
|
|
244
|
+
console.log('Server stopped');
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
vizzly.on('screenshot:captured', (name, metadata) => {
|
|
248
|
+
console.log(`Screenshot captured: ${name}`);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
vizzly.on('upload:progress', (progress) => {
|
|
252
|
+
console.log(`Upload progress: ${progress.completed}/${progress.total}`);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
vizzly.on('upload:completed', (buildId) => {
|
|
256
|
+
console.log(`Upload completed: ${buildId}`);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
vizzly.on('upload:failed', (error) => {
|
|
260
|
+
console.error('Upload failed:', error);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
vizzly.on('comparison:completed', (result) => {
|
|
264
|
+
console.log(`Comparison completed: ${result.name}`);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
vizzly.on('comparison:failed', (error) => {
|
|
268
|
+
console.error('Comparison failed:', error);
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## CLI Commands
|
|
273
|
+
|
|
274
|
+
### `vizzly upload <path>`
|
|
275
|
+
|
|
276
|
+
Upload screenshots from a directory.
|
|
277
|
+
|
|
278
|
+
**Arguments:**
|
|
279
|
+
- `<path>` - Path to screenshots directory
|
|
280
|
+
|
|
281
|
+
**Options:**
|
|
282
|
+
- `-b, --build-name <name>` - Build name
|
|
283
|
+
- `-m, --metadata <json>` - Additional metadata as JSON
|
|
284
|
+
- `--branch <branch>` - Git branch override
|
|
285
|
+
- `--commit <sha>` - Git commit SHA override
|
|
286
|
+
- `--message <msg>` - Commit message override
|
|
287
|
+
- `--environment <env>` - Environment name (default: "test")
|
|
288
|
+
- `--threshold <number>` - Comparison threshold (0-1)
|
|
289
|
+
- `--token <token>` - API token override
|
|
290
|
+
- `--wait` - Wait for build completion
|
|
291
|
+
|
|
292
|
+
**Exit Codes:**
|
|
293
|
+
- `0` - Success (all approved or no changes)
|
|
294
|
+
- `1` - Changes detected (requires review)
|
|
295
|
+
- `2` - Upload failed or error
|
|
296
|
+
|
|
297
|
+
### `vizzly run <command>`
|
|
298
|
+
|
|
299
|
+
Run tests with Vizzly integration.
|
|
300
|
+
|
|
301
|
+
**Arguments:**
|
|
302
|
+
- `<command>` - Test command to execute
|
|
303
|
+
|
|
304
|
+
**Options:**
|
|
305
|
+
|
|
306
|
+
*Server Configuration:*
|
|
307
|
+
- `--port <port>` - Server port (default: 47392)
|
|
308
|
+
- `--timeout <ms>` - Server timeout in milliseconds (default: 30000)
|
|
309
|
+
|
|
310
|
+
*Build Configuration:*
|
|
311
|
+
- `-b, --build-name <name>` - Custom build name
|
|
312
|
+
- `--branch <branch>` - Git branch override
|
|
313
|
+
- `--commit <sha>` - Git commit SHA override
|
|
314
|
+
- `--message <msg>` - Commit message override
|
|
315
|
+
- `--environment <env>` - Environment name (default: "test")
|
|
316
|
+
|
|
317
|
+
*Processing Options:*
|
|
318
|
+
- `--wait` - Wait for build completion and exit with appropriate code
|
|
319
|
+
- `--eager` - Create build immediately (default: lazy creation)
|
|
320
|
+
- `--threshold <number>` - Comparison threshold (0-1, default: 0.01)
|
|
321
|
+
- `--upload-timeout <ms>` - Upload wait timeout in ms (default: from config or 30000)
|
|
322
|
+
|
|
323
|
+
*Development & Testing:*
|
|
324
|
+
- `--tdd` - Enable TDD mode with local comparisons
|
|
325
|
+
- `--allow-no-token` - Allow running without API token
|
|
326
|
+
- `--token <token>` - API token override
|
|
327
|
+
|
|
328
|
+
*Baseline Configuration:*
|
|
329
|
+
- `--baseline-build <id>` - Use specific build as baseline for comparisons
|
|
330
|
+
- `--baseline-comparison <id>` - Use specific comparison as baseline
|
|
331
|
+
|
|
332
|
+
**Environment Variables Set:**
|
|
333
|
+
- `VIZZLY_SERVER_URL` - Local server URL
|
|
334
|
+
- `VIZZLY_BUILD_ID` - Current build ID
|
|
335
|
+
- `VIZZLY_ENABLED` - Set to "true"
|
|
336
|
+
- `VIZZLY_TDD_MODE` - "true" if TDD mode active
|
|
337
|
+
|
|
338
|
+
**Exit Codes:**
|
|
339
|
+
- `0` - Success
|
|
340
|
+
- `1` - Visual differences detected (when using `--wait`)
|
|
341
|
+
- `2` - Build failed or error
|
|
342
|
+
|
|
343
|
+
### `vizzly tdd <command>`
|
|
344
|
+
|
|
345
|
+
Run tests in TDD mode with local visual comparisons.
|
|
346
|
+
|
|
347
|
+
**Arguments:**
|
|
348
|
+
- `<command>` - Test command to execute
|
|
349
|
+
|
|
350
|
+
**Options:**
|
|
351
|
+
|
|
352
|
+
*Server Configuration:*
|
|
353
|
+
- `--port <port>` - Server port (default: 47392)
|
|
354
|
+
- `--timeout <ms>` - Server timeout in milliseconds (default: 30000)
|
|
355
|
+
|
|
356
|
+
*Baseline Management:*
|
|
357
|
+
- `--set-baseline` - Accept current screenshots as new baseline (overwrites existing)
|
|
358
|
+
- `--baseline-build <id>` - Use specific build as baseline (requires API token)
|
|
359
|
+
- `--baseline-comparison <id>` - Use specific comparison as baseline (requires API token)
|
|
360
|
+
|
|
361
|
+
*Build Configuration:*
|
|
362
|
+
- `--branch <branch>` - Git branch override
|
|
363
|
+
- `--environment <env>` - Environment name (default: "test")
|
|
364
|
+
- `--threshold <number>` - Comparison threshold (0-1, default: 0.1)
|
|
365
|
+
- `--token <token>` - API token override
|
|
366
|
+
|
|
367
|
+
**Behavior:**
|
|
368
|
+
- 🐻 **No API token**: Auto-detected, runs in local-only mode
|
|
369
|
+
- 🐻 **First run**: Creates local baseline from screenshots
|
|
370
|
+
- 🐻 **Subsequent runs**: Compares against local baseline, **tests fail on differences**
|
|
371
|
+
- 🐻 **`--set-baseline`**: Accepts current screenshots as new baseline
|
|
372
|
+
|
|
373
|
+
**Environment Variables Set:**
|
|
374
|
+
- `VIZZLY_SERVER_URL` - Local server URL
|
|
375
|
+
- `VIZZLY_BUILD_ID` - Current build ID
|
|
376
|
+
- `VIZZLY_ENABLED` - Set to "true"
|
|
377
|
+
- `VIZZLY_SET_BASELINE` - "true" if `--set-baseline` used
|
|
378
|
+
|
|
379
|
+
**Exit Codes:**
|
|
380
|
+
- `0` - Success (no visual differences or baseline update mode)
|
|
381
|
+
- `1` - Visual differences detected (comparison failed)
|
|
382
|
+
- `2` - TDD mode failed or error
|
|
383
|
+
|
|
384
|
+
### `vizzly init [directory]`
|
|
385
|
+
|
|
386
|
+
Initialize Vizzly configuration.
|
|
387
|
+
|
|
388
|
+
**Arguments:**
|
|
389
|
+
- `[directory]` - Target directory (default: current)
|
|
390
|
+
|
|
391
|
+
**Options:**
|
|
392
|
+
- `--force` - Overwrite existing configuration
|
|
393
|
+
|
|
394
|
+
**Generated Files:**
|
|
395
|
+
- `vizzly.config.js` - Configuration file
|
|
396
|
+
|
|
397
|
+
### `vizzly status <build-id>`
|
|
398
|
+
|
|
399
|
+
Check build status.
|
|
400
|
+
|
|
401
|
+
**Arguments:**
|
|
402
|
+
- `<build-id>` - Build ID to check
|
|
403
|
+
|
|
404
|
+
**Exit Codes:**
|
|
405
|
+
- `0` - Build completed successfully
|
|
406
|
+
- `1` - Build has changes requiring review
|
|
407
|
+
- `2` - Build failed or error
|
|
408
|
+
|
|
409
|
+
### `vizzly doctor`
|
|
410
|
+
|
|
411
|
+
Run environment diagnostics.
|
|
412
|
+
|
|
413
|
+
**Checks:**
|
|
414
|
+
- Node.js version (>= 20.0.0)
|
|
415
|
+
- npm installation
|
|
416
|
+
- Package.json existence
|
|
417
|
+
- Vizzly configuration loading
|
|
418
|
+
- API connectivity (if token available)
|
|
419
|
+
- Required dependencies
|
|
420
|
+
- File permissions
|
|
421
|
+
- Port availability
|
|
422
|
+
|
|
423
|
+
## Global CLI Options
|
|
424
|
+
|
|
425
|
+
Available on all commands:
|
|
426
|
+
|
|
427
|
+
- `-c, --config <path>` - Config file path
|
|
428
|
+
- `--token <token>` - Vizzly API token
|
|
429
|
+
- `-v, --verbose` - Verbose output
|
|
430
|
+
- `--json` - Machine-readable JSON output
|
|
431
|
+
- `--no-color` - Disable colored output
|
|
432
|
+
|
|
433
|
+
## Configuration
|
|
434
|
+
|
|
435
|
+
### File Locations
|
|
436
|
+
|
|
437
|
+
Configuration loaded via cosmiconfig in this order:
|
|
438
|
+
|
|
439
|
+
1. Command line `--config` option
|
|
440
|
+
2. `vizzly.config.js`
|
|
441
|
+
3. `.vizzlyrc.js`
|
|
442
|
+
4. `vizzly` key in `package.json`
|
|
443
|
+
5. Environment variables
|
|
444
|
+
6. CLI option overrides
|
|
445
|
+
|
|
446
|
+
### Configuration Schema
|
|
447
|
+
|
|
448
|
+
```javascript
|
|
449
|
+
{
|
|
450
|
+
// API Configuration
|
|
451
|
+
apiKey: string, // API token (from VIZZLY_TOKEN)
|
|
452
|
+
apiUrl: string, // API base URL (default: 'https://vizzly.dev')
|
|
453
|
+
project: string, // Project ID override
|
|
454
|
+
|
|
455
|
+
// Server Configuration (for run command)
|
|
456
|
+
server: {
|
|
457
|
+
port: number, // Server port (default: 47392)
|
|
458
|
+
timeout: number, // Timeout in ms (default: 30000)
|
|
459
|
+
screenshotPath: string // Screenshot endpoint path
|
|
460
|
+
},
|
|
461
|
+
|
|
462
|
+
// Build Configuration
|
|
463
|
+
build: {
|
|
464
|
+
name: string, // Build name template
|
|
465
|
+
environment: string // Environment name (default: 'test')
|
|
466
|
+
},
|
|
467
|
+
|
|
468
|
+
// Upload Configuration (for upload command)
|
|
469
|
+
upload: {
|
|
470
|
+
screenshotsDir: string, // Screenshots directory (default: './screenshots')
|
|
471
|
+
batchSize: number, // Upload batch size (default: 10)
|
|
472
|
+
timeout: number, // Upload timeout in ms (default: 30000)
|
|
473
|
+
retries: number // Retry attempts (default: 3)
|
|
474
|
+
},
|
|
475
|
+
|
|
476
|
+
// Comparison Configuration
|
|
477
|
+
comparison: {
|
|
478
|
+
threshold: number, // Pixel difference threshold (default: 0.01)
|
|
479
|
+
ignoreAntialiasing: boolean, // Ignore antialiasing (default: true)
|
|
480
|
+
ignoreColors: boolean // Ignore color differences (default: false)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Environment Variables
|
|
486
|
+
|
|
487
|
+
- `VIZZLY_TOKEN` - API authentication token
|
|
488
|
+
- `VIZZLY_API_URL` - API base URL override
|
|
489
|
+
- `VIZZLY_LOG_LEVEL` - Logger level (`debug`, `info`, `warn`, `error`)
|
|
490
|
+
- `VIZZLY_SERVER_URL` - Screenshot server URL (set by CLI)
|
|
491
|
+
- `VIZZLY_ENABLED` - Enable/disable client (set by CLI)
|
|
492
|
+
- `VIZZLY_BUILD_ID` - Current build ID (set by CLI)
|
|
493
|
+
- `VIZZLY_TDD_MODE` - TDD mode active (set by CLI)
|
|
494
|
+
|
|
495
|
+
## Error Handling
|
|
496
|
+
|
|
497
|
+
### Client Errors
|
|
498
|
+
|
|
499
|
+
```javascript
|
|
500
|
+
try {
|
|
501
|
+
await vizzlyScreenshot('test', screenshot);
|
|
502
|
+
} catch (error) {
|
|
503
|
+
if (error.code === 'VIZZLY_DISABLED') {
|
|
504
|
+
// Vizzly is disabled, skip screenshot
|
|
505
|
+
} else if (error.code === 'VIZZLY_SERVER_UNAVAILABLE') {
|
|
506
|
+
// Server not reachable
|
|
507
|
+
} else {
|
|
508
|
+
// Other error
|
|
509
|
+
throw error;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### Common Error Codes
|
|
515
|
+
|
|
516
|
+
- `VIZZLY_DISABLED` - Screenshot capture disabled
|
|
517
|
+
- `VIZZLY_SERVER_UNAVAILABLE` - Local server not reachable
|
|
518
|
+
- `VIZZLY_INVALID_IMAGE` - Invalid image buffer provided
|
|
519
|
+
- `VIZZLY_UPLOAD_FAILED` - Upload to Vizzly failed
|
|
520
|
+
- `VIZZLY_COMPARISON_FAILED` - Local comparison failed
|
|
521
|
+
- `VIZZLY_TOKEN_MISSING` - API token not provided
|
|
522
|
+
- `VIZZLY_TOKEN_INVALID` - API token invalid or expired
|
|
523
|
+
|
|
524
|
+
## TypeScript Support
|
|
525
|
+
|
|
526
|
+
The CLI includes comprehensive TypeScript definitions:
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
import { vizzlyScreenshot, VizzlyOptions, VizzlyInfo } from '@vizzly-testing/cli/client';
|
|
530
|
+
|
|
531
|
+
const options: VizzlyOptions = {
|
|
532
|
+
threshold: 0.01,
|
|
533
|
+
properties: {
|
|
534
|
+
browser: 'chrome',
|
|
535
|
+
viewport: '1920x1080'
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
await vizzlyScreenshot('homepage', screenshot, options);
|
|
540
|
+
|
|
541
|
+
const info: VizzlyInfo = getVizzlyInfo();
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
## Migration Guide
|
|
545
|
+
|
|
546
|
+
### From Direct API Usage
|
|
547
|
+
|
|
548
|
+
If you were using direct API calls:
|
|
549
|
+
|
|
550
|
+
```javascript
|
|
551
|
+
// Before
|
|
552
|
+
await fetch('https://api.vizzly.dev/screenshots', {
|
|
553
|
+
method: 'POST',
|
|
554
|
+
body: formData
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
// After
|
|
558
|
+
import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
|
|
559
|
+
await vizzlyScreenshot('homepage', screenshot);
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### From Other Visual Testing Tools
|
|
563
|
+
|
|
564
|
+
The Vizzly client API is designed to be a drop-in replacement:
|
|
565
|
+
|
|
566
|
+
```javascript
|
|
567
|
+
// Percy
|
|
568
|
+
await percy.snapshot('homepage');
|
|
569
|
+
|
|
570
|
+
// Vizzly equivalent
|
|
571
|
+
await vizzlyScreenshot('homepage', screenshot);
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
## Best Practices
|
|
575
|
+
|
|
576
|
+
### Screenshot Naming
|
|
577
|
+
- Use descriptive, consistent names
|
|
578
|
+
- Include page/component context
|
|
579
|
+
- Avoid spaces and special characters
|
|
580
|
+
|
|
581
|
+
### Metadata Organization
|
|
582
|
+
- Use consistent property names across tests
|
|
583
|
+
- Include browser/device information
|
|
584
|
+
- Add environment context
|
|
585
|
+
|
|
586
|
+
### Performance
|
|
587
|
+
- Don't take unnecessary screenshots
|
|
588
|
+
- Use appropriate image sizes
|
|
589
|
+
- Consider test execution time
|
|
590
|
+
|
|
591
|
+
### Error Handling
|
|
592
|
+
- Check if Vizzly is enabled before capturing
|
|
593
|
+
- Handle network failures gracefully
|
|
594
|
+
- Log errors for debugging
|
|
595
|
+
|
|
596
|
+
## Support
|
|
597
|
+
|
|
598
|
+
For additional help:
|
|
599
|
+
|
|
600
|
+
- Check [Getting Started Guide](./getting-started.md)
|
|
601
|
+
- Review [Test Integration Guide](./test-integration.md)
|
|
602
|
+
- Explore [TDD Mode Guide](./tdd-mode.md)
|
|
603
|
+
- Report issues at [GitHub Issues](https://github.com/vizzly-testing/cli/issues)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Doctor Command
|
|
2
|
+
|
|
3
|
+
The `doctor` command provides a quick preflight to validate your local setup. It is designed to be fast and non-invasive by default.
|
|
4
|
+
|
|
5
|
+
## Summary
|
|
6
|
+
|
|
7
|
+
- Local-only checks by default (no network)
|
|
8
|
+
- Optional API connectivity check via `--api`
|
|
9
|
+
- Node.js 20+ required
|
|
10
|
+
|
|
11
|
+
## What It Checks
|
|
12
|
+
|
|
13
|
+
- Node.js version: must be 20 or newer
|
|
14
|
+
- `apiUrl`: must be a valid `http` or `https` URL
|
|
15
|
+
- `comparison.threshold`: a number between 0 and 1
|
|
16
|
+
- Effective `server.port`: reports the port without binding (default `47392`)
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Local-only checks
|
|
22
|
+
vizzly doctor
|
|
23
|
+
|
|
24
|
+
# Include API connectivity checks (requires VIZZLY_TOKEN)
|
|
25
|
+
vizzly doctor --api
|
|
26
|
+
|
|
27
|
+
# JSON output for CI/tooling
|
|
28
|
+
vizzly doctor --json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Environment Variables
|
|
32
|
+
|
|
33
|
+
- `VIZZLY_API_URL` — Override the API base URL (default: `https://vizzly.dev`)
|
|
34
|
+
- `VIZZLY_TOKEN` — API token used only when `--api` is provided
|
|
35
|
+
|
|
36
|
+
## Exit Codes
|
|
37
|
+
|
|
38
|
+
- `0` — All requested checks passed
|
|
39
|
+
- `1` — One or more checks failed
|
|
40
|
+
|
|
41
|
+
## Notes
|
|
42
|
+
|
|
43
|
+
- The `--api` flag performs a minimal, read-only API request to verify connectivity.
|
|
44
|
+
- The command does not bind or reserve the configured port; it only reports it.
|