@vizzly-testing/cli 0.23.1 → 0.24.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.
Files changed (45) hide show
  1. package/README.md +54 -586
  2. package/dist/api/client.js +3 -1
  3. package/dist/api/endpoints.js +6 -7
  4. package/dist/cli.js +15 -2
  5. package/dist/commands/finalize.js +12 -0
  6. package/dist/commands/preview.js +210 -28
  7. package/dist/commands/run.js +15 -0
  8. package/dist/commands/status.js +34 -8
  9. package/dist/commands/upload.js +13 -0
  10. package/dist/reporter/reporter-bundle.css +1 -1
  11. package/dist/reporter/reporter-bundle.iife.js +71 -63
  12. package/dist/server/handlers/tdd-handler.js +4 -9
  13. package/dist/tdd/core/region-coverage.js +115 -0
  14. package/dist/tdd/core/signature.js +3 -1
  15. package/dist/tdd/metadata/region-metadata.js +93 -0
  16. package/dist/tdd/services/comparison-service.js +40 -8
  17. package/dist/tdd/services/region-service.js +75 -0
  18. package/dist/tdd/tdd-service.js +70 -8
  19. package/package.json +3 -4
  20. package/claude-plugin/.claude-plugin/README.md +0 -270
  21. package/claude-plugin/.claude-plugin/marketplace.json +0 -28
  22. package/claude-plugin/.claude-plugin/plugin.json +0 -14
  23. package/claude-plugin/.mcp.json +0 -12
  24. package/claude-plugin/CHANGELOG.md +0 -85
  25. package/claude-plugin/commands/setup.md +0 -137
  26. package/claude-plugin/commands/suggest-screenshots.md +0 -111
  27. package/claude-plugin/mcp/vizzly-docs-server/README.md +0 -95
  28. package/claude-plugin/mcp/vizzly-docs-server/docs-fetcher.js +0 -110
  29. package/claude-plugin/mcp/vizzly-docs-server/index.js +0 -283
  30. package/claude-plugin/mcp/vizzly-server/cloud-api-provider.js +0 -399
  31. package/claude-plugin/mcp/vizzly-server/index.js +0 -927
  32. package/claude-plugin/mcp/vizzly-server/local-tdd-provider.js +0 -455
  33. package/claude-plugin/mcp/vizzly-server/token-resolver.js +0 -185
  34. package/claude-plugin/skills/check-visual-tests/SKILL.md +0 -158
  35. package/claude-plugin/skills/debug-visual-regression/SKILL.md +0 -269
  36. package/docs/api-reference.md +0 -1003
  37. package/docs/authentication.md +0 -334
  38. package/docs/doctor-command.md +0 -44
  39. package/docs/getting-started.md +0 -131
  40. package/docs/internal/SDK-API.md +0 -1018
  41. package/docs/plugins.md +0 -557
  42. package/docs/tdd-mode.md +0 -594
  43. package/docs/test-integration.md +0 -523
  44. package/docs/tui-elements.md +0 -560
  45. package/docs/upload-command.md +0 -196
@@ -1,1003 +0,0 @@
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 | string) - PNG image data as Buffer, or file path to an image
16
- - `options` (object, optional) - Configuration and metadata
17
-
18
- **Options:**
19
- ```javascript
20
- {
21
- // Comparison settings
22
- threshold: 2.0, // CIEDE2000 Delta E (0=exact, 1=JND, 2=recommended)
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
- **Examples:**
43
-
44
- Using a Buffer:
45
-
46
- ```javascript
47
- import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
48
-
49
- const screenshot = await page.screenshot();
50
- await vizzlyScreenshot('homepage', screenshot, {
51
- threshold: 0.02,
52
- properties: {
53
- browser: 'chrome',
54
- viewport: '1920x1080',
55
- component: 'hero-section'
56
- }
57
- });
58
- ```
59
-
60
- Using a file path:
61
-
62
- ```javascript
63
- import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
64
-
65
- // Save screenshot to file
66
- await page.screenshot({ path: './screenshots/homepage.png' });
67
-
68
- // Send to Vizzly using file path
69
- await vizzlyScreenshot('homepage', './screenshots/homepage.png', {
70
- threshold: 0.02,
71
- properties: {
72
- browser: 'chrome',
73
- viewport: '1920x1080',
74
- component: 'hero-section'
75
- }
76
- });
77
- ```
78
-
79
- **File Path Support:**
80
- - Accepts both absolute and relative paths
81
- - Automatically reads the file and converts to Buffer internally
82
- - Throws error if file doesn't exist or cannot be read
83
- - Works with any PNG image file
84
-
85
- ### `vizzlyFlush()`
86
-
87
- Signal test completion and trigger the results summary. Call this in your test framework's global teardown to see a summary of all visual comparisons.
88
-
89
- **Returns:** `Promise<{ success: boolean, summary: object } | null>`
90
-
91
- **Summary object:**
92
- ```javascript
93
- {
94
- total: number, // Total screenshots compared
95
- passed: number, // Screenshots that matched baseline
96
- failed: number, // Screenshots with visual differences
97
- new: number, // New screenshots (no baseline)
98
- errors: number // Screenshots that failed to process
99
- }
100
- ```
101
-
102
- **Example - Playwright global teardown:**
103
- ```javascript
104
- // playwright.config.js or global-teardown.js
105
- import { vizzlyFlush } from '@vizzly-testing/cli/client';
106
-
107
- export default async function globalTeardown() {
108
- await vizzlyFlush();
109
- }
110
- ```
111
-
112
- **Example - Jest/Vitest:**
113
- ```javascript
114
- import { vizzlyFlush } from '@vizzly-testing/cli/client';
115
-
116
- afterAll(async () => {
117
- await vizzlyFlush();
118
- });
119
- ```
120
-
121
- When `vizzlyFlush()` is called, the TDD server prints a summary like:
122
-
123
- ```
124
- [vizzly] 8 screenshots compared
125
-
126
- + 5 passed
127
-
128
- ! 3 visual changes detected
129
- - billing-settings-page
130
- - checkout-form
131
- - profile-page
132
-
133
- > View changes: http://localhost:47392/dashboard
134
- ```
135
-
136
- ### `isVizzlyEnabled()`
137
-
138
- Check if Vizzly screenshot capture is currently enabled.
139
-
140
- **Returns:** `boolean`
141
-
142
- **Example:**
143
- ```javascript
144
- import { isVizzlyEnabled } from '@vizzly-testing/cli/client';
145
-
146
- if (isVizzlyEnabled()) {
147
- const screenshot = await page.screenshot();
148
- await vizzlyScreenshot('conditional-screenshot', screenshot);
149
- }
150
- ```
151
-
152
- ### `getVizzlyInfo()`
153
-
154
- Get current Vizzly environment information and settings.
155
-
156
- **Returns:** `object`
157
- ```javascript
158
- {
159
- enabled: boolean, // Whether Vizzly is active
160
- serverUrl: string, // Local server URL
161
- buildId: string, // Current build ID
162
- tddMode: boolean, // Whether TDD mode is active
163
- version: string // Client version
164
- }
165
- ```
166
-
167
- **Example:**
168
- ```javascript
169
- import { getVizzlyInfo } from '@vizzly-testing/cli/client';
170
-
171
- const info = getVizzlyInfo();
172
- console.log(`Vizzly ${info.enabled ? 'enabled' : 'disabled'}`);
173
- console.log(`TDD Mode: ${info.tddMode}`);
174
- console.log(`Build ID: ${info.buildId}`);
175
- ```
176
-
177
- ### `configure(config)`
178
-
179
- Configure client settings (advanced usage).
180
-
181
- **Parameters:**
182
- - `config` (object) - Configuration options
183
-
184
- **Config Options:**
185
- ```javascript
186
- {
187
- serverUrl: string, // Override server URL
188
- enabled: boolean, // Enable/disable capture
189
- timeout: number, // Request timeout (ms)
190
- retries: number // Number of retry attempts
191
- }
192
- ```
193
-
194
- **Example:**
195
- ```javascript
196
- import { configure } from '@vizzly-testing/cli/client';
197
-
198
- configure({
199
- serverUrl: 'http://localhost:3001',
200
- enabled: true,
201
- timeout: 10000
202
- });
203
- ```
204
-
205
- ### `setEnabled(enabled)`
206
-
207
- Enable or disable screenshot capture.
208
-
209
- **Parameters:**
210
- - `enabled` (boolean) - Whether to enable capture
211
-
212
- **Example:**
213
- ```javascript
214
- import { setEnabled } from '@vizzly-testing/cli/client';
215
-
216
- // Disable screenshots for this test
217
- setEnabled(false);
218
- await runTest();
219
-
220
- // Re-enable
221
- setEnabled(true);
222
- ```
223
-
224
- ## SDK API (`@vizzly-testing/cli/sdk`)
225
-
226
- The SDK provides comprehensive programmatic access to Vizzly functionality.
227
-
228
- ### `createVizzly(config, options)`
229
-
230
- Create a new Vizzly SDK instance.
231
-
232
- **Parameters:**
233
- - `config` (object) - Vizzly configuration
234
- - `options` (object, optional) - SDK options
235
-
236
- **Returns:** `VizzlySDK` instance
237
-
238
- **Example:**
239
- ```javascript
240
- import { createVizzly } from '@vizzly-testing/cli/sdk';
241
-
242
- const vizzly = createVizzly({
243
- apiKey: process.env.VIZZLY_TOKEN,
244
- project: 'my-project'
245
- });
246
- ```
247
-
248
- ### `VizzlySDK` Class
249
-
250
- The main SDK class that extends `EventEmitter`.
251
-
252
- #### Methods
253
-
254
- ##### `start()`
255
- Start the Vizzly server and initialize the SDK.
256
-
257
- **Returns:** `Promise<void>`
258
-
259
- ##### `stop()`
260
- Stop the Vizzly server and cleanup resources.
261
-
262
- **Returns:** `Promise<void>`
263
-
264
- ##### `screenshot(name, imageBuffer, options)`
265
- Capture a screenshot.
266
-
267
- **Parameters:**
268
- - `name` (string) - Unique screenshot identifier
269
- - `imageBuffer` (Buffer | string) - PNG image data as Buffer, or file path to an image
270
- - `options` (object, optional) - Configuration and metadata
271
-
272
- **Returns:** `Promise<void>`
273
-
274
- **Example:**
275
- ```javascript
276
- // Using a Buffer
277
- await vizzly.screenshot('homepage', buffer);
278
-
279
- // Using a file path
280
- await vizzly.screenshot('homepage', './screenshots/homepage.png');
281
- ```
282
-
283
- ##### `upload(options)`
284
- Upload screenshots to Vizzly.
285
-
286
- **Parameters:**
287
- - `options` (object) - Upload configuration
288
-
289
- **Options:**
290
- ```javascript
291
- {
292
- screenshotsDir: string, // Directory containing screenshots
293
- buildName: string, // Build name
294
- environment: string, // Environment name
295
- wait: boolean // Wait for completion
296
- }
297
- ```
298
-
299
- ##### `compare(name, imageBuffer)`
300
- Run local comparison (TDD mode).
301
-
302
- **Parameters:**
303
- - `name` (string) - Screenshot name
304
- - `imageBuffer` (Buffer | string) - PNG image data as Buffer, or file path to an image
305
-
306
- **Returns:** `Promise<ComparisonResult>`
307
-
308
- **Example:**
309
- ```javascript
310
- // Using a Buffer
311
- const result = await vizzly.compare('homepage', buffer);
312
-
313
- // Using a file path
314
- const result = await vizzly.compare('homepage', './screenshots/homepage.png');
315
- ```
316
-
317
- ##### `getConfig()`
318
- Get current SDK configuration.
319
-
320
- **Returns:** `object` - Current configuration
321
-
322
- #### Events
323
-
324
- The SDK emits various events for monitoring:
325
-
326
- ```javascript
327
- vizzly.on('server:started', (port) => {
328
- console.log(`Server started on port ${port}`);
329
- });
330
-
331
- vizzly.on('server:stopped', () => {
332
- console.log('Server stopped');
333
- });
334
-
335
- vizzly.on('screenshot:captured', (name, metadata) => {
336
- console.log(`Screenshot captured: ${name}`);
337
- });
338
-
339
- vizzly.on('upload:progress', (progress) => {
340
- console.log(`Upload progress: ${progress.completed}/${progress.total}`);
341
- });
342
-
343
- vizzly.on('upload:completed', (buildId) => {
344
- console.log(`Upload completed: ${buildId}`);
345
- });
346
-
347
- vizzly.on('upload:failed', (error) => {
348
- console.error('Upload failed:', error);
349
- });
350
-
351
- vizzly.on('comparison:completed', (result) => {
352
- console.log(`Comparison completed: ${result.name}`);
353
- });
354
-
355
- vizzly.on('comparison:failed', (error) => {
356
- console.error('Comparison failed:', error);
357
- });
358
- ```
359
-
360
- ## CLI Commands
361
-
362
- ### Authentication Commands
363
-
364
- #### `vizzly login`
365
-
366
- Authenticate using OAuth 2.0 device flow.
367
-
368
- **Options:**
369
- - `--json` - Machine-readable JSON output
370
- - `--verbose` - Verbose output
371
-
372
- **Exit Codes:**
373
- - `0` - Login successful
374
- - `1` - Login failed
375
-
376
- **Example:**
377
- ```bash
378
- vizzly login
379
- ```
380
-
381
- #### `vizzly logout`
382
-
383
- Clear stored authentication tokens.
384
-
385
- **Options:**
386
- - `--json` - Machine-readable JSON output
387
- - `--verbose` - Verbose output
388
-
389
- **Exit Codes:**
390
- - `0` - Logout successful
391
- - `1` - Logout failed
392
-
393
- **Example:**
394
- ```bash
395
- vizzly logout
396
- ```
397
-
398
- #### `vizzly whoami`
399
-
400
- Display current user and authentication status.
401
-
402
- **Options:**
403
- - `--json` - Machine-readable JSON output
404
-
405
- **Exit Codes:**
406
- - `0` - Success
407
- - `1` - Not authenticated or error
408
-
409
- **Example:**
410
- ```bash
411
- vizzly whoami
412
- ```
413
-
414
- #### `vizzly project:select`
415
-
416
- Configure project-specific token for current directory.
417
-
418
- **Options:**
419
- - `--json` - Machine-readable JSON output
420
-
421
- **Exit Codes:**
422
- - `0` - Project configured successfully
423
- - `1` - Configuration failed
424
-
425
- **Example:**
426
- ```bash
427
- cd /path/to/project
428
- vizzly project:select
429
- ```
430
-
431
- #### `vizzly project:list`
432
-
433
- Show all configured projects.
434
-
435
- **Exit Codes:**
436
- - `0` - Success
437
- - `1` - Error
438
-
439
- **Example:**
440
- ```bash
441
- vizzly project:list
442
- ```
443
-
444
- #### `vizzly project:token`
445
-
446
- Display project token for current directory.
447
-
448
- **Options:**
449
- - `--json` - Machine-readable JSON output
450
-
451
- **Exit Codes:**
452
- - `0` - Success
453
- - `1` - No project configured or error
454
-
455
- **Example:**
456
- ```bash
457
- vizzly project:token
458
- ```
459
-
460
- #### `vizzly project:remove`
461
-
462
- Remove project configuration for current directory.
463
-
464
- **Exit Codes:**
465
- - `0` - Success
466
- - `1` - No project configured or error
467
-
468
- **Example:**
469
- ```bash
470
- vizzly project:remove
471
- ```
472
-
473
- ### `vizzly upload <path>`
474
-
475
- Upload screenshots from a directory.
476
-
477
- **Arguments:**
478
- - `<path>` - Path to screenshots directory
479
-
480
- **Options:**
481
- - `-b, --build-name <name>` - Build name
482
- - `-m, --metadata <json>` - Additional metadata as JSON
483
- - `--branch <branch>` - Git branch override
484
- - `--commit <sha>` - Git commit SHA override
485
- - `--message <msg>` - Commit message override
486
- - `--environment <env>` - Environment name (default: "test")
487
- - `--threshold <number>` - Comparison threshold (CIEDE2000 Delta E)
488
- - `--token <token>` - API token override
489
- - `--wait` - Wait for build completion
490
- - `--upload-all` - Upload all screenshots without SHA deduplication
491
- - `--parallel-id <id>` - Unique identifier for parallel test execution
492
-
493
- **Exit Codes:**
494
- - `0` - Success (all approved or no changes)
495
- - `1` - Changes detected (requires review)
496
- - `2` - Upload failed or error
497
-
498
- ### `vizzly run <command>`
499
-
500
- Run tests with Vizzly integration.
501
-
502
- **Arguments:**
503
- - `<command>` - Test command to execute
504
-
505
- **Options:**
506
-
507
- *Server Configuration:*
508
- - `--port <port>` - Server port (default: 47392)
509
- - `--timeout <ms>` - Server timeout in milliseconds (default: 30000)
510
-
511
- *Build Configuration:*
512
- - `-b, --build-name <name>` - Custom build name
513
- - `--branch <branch>` - Git branch override
514
- - `--commit <sha>` - Git commit SHA override
515
- - `--message <msg>` - Commit message override
516
- - `--environment <env>` - Environment name (default: "test")
517
-
518
- *Processing Options:*
519
- - `--wait` - Wait for build completion and exit with appropriate code
520
- - `--threshold <number>` - Comparison threshold (CIEDE2000 Delta E, default: 2.0)
521
- - `--upload-timeout <ms>` - Upload wait timeout in ms (default: from config or 30000)
522
- - `--upload-all` - Upload all screenshots without SHA deduplication
523
-
524
- *Parallel Execution:*
525
- - `--parallel-id <id>` - Unique identifier for parallel test execution
526
-
527
- *Development & Testing:*
528
- - `--allow-no-token` - Allow running without API token
529
- - `--token <token>` - API token override
530
-
531
-
532
- **Environment Variables Set:**
533
- - `VIZZLY_SERVER_URL` - Local server URL
534
- - `VIZZLY_BUILD_ID` - Current build ID
535
- - `VIZZLY_ENABLED` - Set to "true"
536
- - `VIZZLY_TDD_MODE` - "true" if TDD mode active
537
-
538
- **Exit Codes:**
539
- - `0` - Success
540
- - `1` - Visual differences detected (when using `--wait`)
541
- - `2` - Build failed or error
542
-
543
- ### `vizzly tdd <command>`
544
-
545
- Run tests in TDD mode with local visual comparisons.
546
-
547
- **Arguments:**
548
- - `<command>` - Test command to execute
549
-
550
- **Options:**
551
-
552
- *Server Configuration:*
553
- - `--port <port>` - Server port (default: 47392)
554
- - `--timeout <ms>` - Server timeout in milliseconds (default: 30000)
555
-
556
- *Baseline Management:*
557
- - `--set-baseline` - Accept current screenshots as new baseline (overwrites existing)
558
- - `--baseline-build <id>` - Use specific build as baseline (requires API token)
559
- - `--baseline-comparison <id>` - Use specific comparison as baseline (requires API token)
560
-
561
- *Build Configuration:*
562
- - `--branch <branch>` - Git branch override
563
- - `--environment <env>` - Environment name (default: "test")
564
- - `--threshold <number>` - Comparison threshold (CIEDE2000 Delta E, default: 2.0)
565
- - `--token <token>` - API token override
566
-
567
- **Behavior:**
568
- - 🐻 **No API token**: Auto-detected, runs in local-only mode
569
- - 🐻 **First run**: Creates local baseline from screenshots
570
- - 🐻 **Subsequent runs**: Compares against local baseline, **tests fail on differences**
571
- - 🐻 **`--set-baseline`**: Accepts current screenshots as new baseline
572
-
573
- **Environment Variables Set:**
574
- - `VIZZLY_SERVER_URL` - Local server URL
575
- - `VIZZLY_BUILD_ID` - Current build ID
576
- - `VIZZLY_ENABLED` - Set to "true"
577
- - `VIZZLY_SET_BASELINE` - "true" if `--set-baseline` used
578
-
579
- **Exit Codes:**
580
- - `0` - Success (no visual differences or baseline update mode)
581
- - `1` - Visual differences detected (comparison failed)
582
- - `2` - TDD mode failed or error
583
-
584
- ### `vizzly init [directory]`
585
-
586
- Initialize Vizzly configuration.
587
-
588
- **Arguments:**
589
- - `[directory]` - Target directory (default: current)
590
-
591
- **Options:**
592
- - `--force` - Overwrite existing configuration
593
-
594
- **Generated Files:**
595
- - `vizzly.config.js` - Configuration file
596
-
597
- ### `vizzly status <build-id>`
598
-
599
- Check build status.
600
-
601
- **Arguments:**
602
- - `<build-id>` - Build ID to check
603
-
604
- **Exit Codes:**
605
- - `0` - Build completed successfully
606
- - `1` - Build has changes requiring review
607
- - `2` - Build failed or error
608
-
609
- ### `vizzly finalize <parallel-id>`
610
-
611
- Finalize a parallel build after all shards complete.
612
-
613
- **Arguments:**
614
- - `<parallel-id>` - Parallel ID to finalize
615
-
616
- **Description:**
617
- When using parallel execution with `--parallel-id`, all test shards contribute screenshots to the same shared build. After all shards complete successfully, use this command to finalize the build and trigger comparison processing.
618
-
619
- **Example:**
620
- ```bash
621
- # After all parallel shards complete
622
- vizzly finalize "ci-run-123-attempt-1"
623
- ```
624
-
625
- **Exit Codes:**
626
- - `0` - Build finalized successfully
627
- - `1` - Finalization failed or error
628
-
629
- ### `vizzly doctor`
630
-
631
- Run environment diagnostics.
632
-
633
- **Checks:**
634
- - Node.js version (>= 20.0.0)
635
- - npm installation
636
- - Package.json existence
637
- - Vizzly configuration loading
638
- - API connectivity (if token available)
639
- - Required dependencies
640
- - File permissions
641
- - Port availability
642
-
643
- ## Global CLI Options
644
-
645
- Available on all commands:
646
-
647
- - `-c, --config <path>` - Config file path
648
- - `--token <token>` - Vizzly API token
649
- - `-v, --verbose` - Verbose output (shorthand for `--log-level debug`)
650
- - `--log-level <level>` - Log level: `debug`, `info`, `warn`, `error` (default: `info`, or `VIZZLY_LOG_LEVEL` env var)
651
- - `--json` - Machine-readable JSON output
652
- - `--no-color` - Disable colored output
653
-
654
- ## Configuration
655
-
656
- ### File Locations
657
-
658
- Configuration loaded via cosmiconfig in this order:
659
-
660
- 1. Command line `--config` option
661
- 2. `vizzly.config.js`
662
- 3. `.vizzlyrc.js`
663
- 4. `vizzly` key in `package.json`
664
- 5. Environment variables
665
- 6. CLI option overrides
666
-
667
- ### Configuration Schema
668
-
669
- ```javascript
670
- {
671
- // API Configuration
672
- apiKey: string, // API token (from VIZZLY_TOKEN)
673
- apiUrl: string, // API base URL (default: 'https://app.vizzly.dev')
674
- project: string, // Project ID override
675
-
676
- // Server Configuration (for run command)
677
- server: {
678
- port: number, // Server port (default: 47392)
679
- timeout: number // Timeout in ms (default: 30000)
680
- },
681
-
682
- // Build Configuration
683
- build: {
684
- name: string, // Build name template
685
- environment: string // Environment name (default: 'test')
686
- },
687
-
688
- // Upload Configuration (for upload command)
689
- upload: {
690
- screenshotsDir: string, // Screenshots directory (default: './screenshots')
691
- batchSize: number, // Upload batch size (default: 10)
692
- timeout: number, // Upload timeout in ms (default: 30000)
693
- retries: number // Retry attempts (default: 3)
694
- },
695
-
696
- // Comparison Configuration
697
- comparison: {
698
- threshold: number, // CIEDE2000 Delta E (default: 2.0)
699
- minClusterSize: number // Min cluster size for noise filtering (default: 2)
700
- },
701
-
702
- // Output Configuration
703
- output: {
704
- logLevel: string // Log level: 'debug', 'info', 'warn', 'error' (default: 'info')
705
- }
706
- }
707
- ```
708
-
709
- ### Environment Variables
710
-
711
- All Vizzly CLI behavior can be configured via environment variables. This is the complete reference.
712
-
713
- #### Configuration
714
-
715
- | Variable | Description | Default |
716
- |----------|-------------|---------|
717
- | `VIZZLY_HOME` | Override config directory (auth, project mappings) | `~/.vizzly` |
718
- | `VIZZLY_TOKEN` | API authentication token (project token `vzt_...`) | - |
719
- | `VIZZLY_API_URL` | API base URL | `https://app.vizzly.dev` |
720
- | `VIZZLY_LOG_LEVEL` | Logging verbosity: `debug`, `info`, `warn`, `error` | `info` |
721
-
722
- **Token Priority:** CLI flag → env var → project mapping → user access token
723
-
724
- #### Build & Execution
725
-
726
- | Variable | Description | Default |
727
- |----------|-------------|---------|
728
- | `VIZZLY_PARALLEL_ID` | Unique identifier for parallel test shards | - |
729
- | `VIZZLY_BUILD_ID` | Build identifier for grouping screenshots | Auto-generated |
730
-
731
- #### Git Information Overrides
732
-
733
- Use these in CI/CD to override auto-detected git metadata:
734
-
735
- | Variable | Description |
736
- |----------|-------------|
737
- | `VIZZLY_COMMIT_SHA` | Commit SHA |
738
- | `VIZZLY_COMMIT_MESSAGE` | Commit message |
739
- | `VIZZLY_BRANCH` | Branch name |
740
- | `VIZZLY_PR_NUMBER` | Pull request number |
741
- | `VIZZLY_PR_BASE_REF` | PR base branch name |
742
- | `VIZZLY_PR_BASE_SHA` | PR base commit SHA |
743
- | `VIZZLY_PR_HEAD_REF` | PR head branch name |
744
- | `VIZZLY_PR_HEAD_SHA` | PR head commit SHA |
745
-
746
- **Priority Order:**
747
- 1. CLI arguments (`--commit`, `--branch`, `--message`)
748
- 2. `VIZZLY_*` environment variables
749
- 3. CI-specific variables (e.g., `GITHUB_SHA`, `CI_COMMIT_SHA`)
750
- 4. Git command detection
751
-
752
- #### Runtime (Set by CLI)
753
-
754
- These are set automatically when running `vizzly run` or `vizzly tdd`:
755
-
756
- | Variable | Description |
757
- |----------|-------------|
758
- | `VIZZLY_ENABLED` | `true` when Vizzly capture is active |
759
- | `VIZZLY_SERVER_URL` | Local screenshot server URL |
760
- | `VIZZLY_TDD` | `true` when TDD mode is active |
761
-
762
- #### Advanced
763
-
764
- | Variable | Description |
765
- |----------|-------------|
766
- | `VIZZLY_USER_AGENT` | Custom User-Agent string for API requests |
767
-
768
- ## Controlling Output
769
-
770
- Vizzly is designed to be quiet by default - it won't clutter your test runner output.
771
-
772
- ### Default Behavior
773
-
774
- - **During tests**: Zero output from Vizzly (test runner owns the terminal)
775
- - **After tests**: Summary showing pass/fail counts and dashboard link
776
-
777
- ### When is the Summary Shown?
778
-
779
- The summary is automatically displayed in these scenarios:
780
-
781
- 1. **`vizzly tdd run "npm test"`** - Summary shown when the test command completes
782
- 2. **`vizzlyFlush()` called** - Summary shown when flush is called (use in global teardown)
783
-
784
- If you're using `vizzly tdd start` (daemon mode) and running tests directly, add `vizzlyFlush()` to your test framework's global teardown to see the summary.
785
-
786
- #### Playwright
787
-
788
- ```javascript
789
- // playwright.config.js
790
- export default {
791
- globalTeardown: './global-teardown.js'
792
- };
793
- ```
794
-
795
- ```javascript
796
- // global-teardown.js
797
- import { vizzlyFlush } from '@vizzly-testing/cli/client';
798
-
799
- export default async function globalTeardown() {
800
- // Show Vizzly visual test summary (if TDD server is running)
801
- await vizzlyFlush();
802
-
803
- // ... your other teardown logic
804
- }
805
- ```
806
-
807
- #### Jest
808
-
809
- ```javascript
810
- // jest.config.js
811
- module.exports = {
812
- globalTeardown: './global-teardown.js'
813
- };
814
- ```
815
-
816
- ```javascript
817
- // global-teardown.js
818
- const { vizzlyFlush } = require('@vizzly-testing/cli/client');
819
-
820
- module.exports = async () => {
821
- await vizzlyFlush();
822
- };
823
- ```
824
-
825
- #### Vitest
826
-
827
- ```javascript
828
- // vitest.config.js
829
- export default {
830
- test: {
831
- globalSetup: './global-teardown.js'
832
- }
833
- };
834
- ```
835
-
836
- ```javascript
837
- // global-teardown.js
838
- import { vizzlyFlush } from '@vizzly-testing/cli/client';
839
-
840
- export async function teardown() {
841
- await vizzlyFlush();
842
- }
843
- ```
844
-
845
- ### Example Output
846
-
847
- ```
848
- [vizzly] 8 screenshots compared
849
-
850
- + 5 passed
851
-
852
- ! 3 visual changes detected
853
- - billing-settings-page
854
- - checkout-form
855
- - profile-page
856
-
857
- > View changes: http://localhost:47392/dashboard
858
- ```
859
-
860
- ### Verbose Mode
861
-
862
- Use `--verbose` or `-v` to see per-screenshot details:
863
-
864
- ```bash
865
- vizzly tdd run "npm test" --verbose
866
- ```
867
-
868
- In verbose mode, each screenshot is listed individually with diff percentages for failures.
869
-
870
- ### Environment Variables for Output
871
-
872
- | Variable | Description | Default |
873
- |----------|-------------|---------|
874
- | `VIZZLY_LOG_LEVEL` | CLI verbosity: `debug`, `info`, `warn`, `error` | `info` |
875
- | `VIZZLY_CLIENT_LOG_LEVEL` | Client SDK verbosity (runs in test process) | `error` |
876
-
877
- The client SDK defaults to `error` to minimize noise in test output. Set to `debug` for troubleshooting:
878
-
879
- ```bash
880
- VIZZLY_CLIENT_LOG_LEVEL=debug npm test
881
- ```
882
-
883
- ### Config File
884
-
885
- You can also configure output settings in `vizzly.config.js`:
886
-
887
- ```javascript
888
- export default defineConfig({
889
- output: {
890
- logLevel: 'debug' // Show detailed per-screenshot output
891
- }
892
- });
893
- ```
894
-
895
- ## Error Handling
896
-
897
- ### Client Errors
898
-
899
- ```javascript
900
- try {
901
- await vizzlyScreenshot('test', screenshot);
902
- } catch (error) {
903
- if (error.code === 'VIZZLY_DISABLED') {
904
- // Vizzly is disabled, skip screenshot
905
- } else if (error.code === 'VIZZLY_SERVER_UNAVAILABLE') {
906
- // Server not reachable
907
- } else {
908
- // Other error
909
- throw error;
910
- }
911
- }
912
- ```
913
-
914
- ### Common Error Codes
915
-
916
- - `VIZZLY_DISABLED` - Screenshot capture disabled
917
- - `VIZZLY_SERVER_UNAVAILABLE` - Local server not reachable
918
- - `VIZZLY_INVALID_IMAGE` - Invalid image buffer provided
919
- - `VIZZLY_UPLOAD_FAILED` - Upload to Vizzly failed
920
- - `VIZZLY_COMPARISON_FAILED` - Local comparison failed
921
- - `VIZZLY_TOKEN_MISSING` - API token not provided
922
- - `VIZZLY_TOKEN_INVALID` - API token invalid or expired
923
-
924
- ## TypeScript Support
925
-
926
- The CLI includes comprehensive TypeScript definitions:
927
-
928
- ```typescript
929
- import { vizzlyScreenshot, VizzlyOptions, VizzlyInfo } from '@vizzly-testing/cli/client';
930
-
931
- const options: VizzlyOptions = {
932
- threshold: 0.01,
933
- properties: {
934
- browser: 'chrome',
935
- viewport: '1920x1080'
936
- }
937
- };
938
-
939
- await vizzlyScreenshot('homepage', screenshot, options);
940
-
941
- const info: VizzlyInfo = getVizzlyInfo();
942
- ```
943
-
944
- ## Migration Guide
945
-
946
- ### From Direct API Usage
947
-
948
- If you were using direct API calls:
949
-
950
- ```javascript
951
- // Before
952
- await fetch('https://api.vizzly.dev/screenshots', {
953
- method: 'POST',
954
- body: formData
955
- });
956
-
957
- // After
958
- import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
959
- await vizzlyScreenshot('homepage', screenshot);
960
- ```
961
-
962
- ### From Other Visual Testing Tools
963
-
964
- The Vizzly client API is designed to be a drop-in replacement:
965
-
966
- ```javascript
967
- // Percy
968
- await percy.snapshot('homepage');
969
-
970
- // Vizzly equivalent
971
- await vizzlyScreenshot('homepage', screenshot);
972
- ```
973
-
974
- ## Best Practices
975
-
976
- ### Screenshot Naming
977
- - Use descriptive, consistent names
978
- - Include page/component context
979
- - Avoid spaces and special characters
980
-
981
- ### Metadata Organization
982
- - Use consistent property names across tests
983
- - Include browser/device information
984
- - Add environment context
985
-
986
- ### Performance
987
- - Don't take unnecessary screenshots
988
- - Use appropriate image sizes
989
- - Consider test execution time
990
-
991
- ### Error Handling
992
- - Check if Vizzly is enabled before capturing
993
- - Handle network failures gracefully
994
- - Log errors for debugging
995
-
996
- ## Support
997
-
998
- For additional help:
999
-
1000
- - Check [Getting Started Guide](./getting-started.md)
1001
- - Review [Test Integration Guide](./test-integration.md)
1002
- - Explore [TDD Mode Guide](./tdd-mode.md)
1003
- - Report issues at [GitHub Issues](https://github.com/vizzly-testing/cli/issues)