@vizzly-testing/cli 0.3.1 → 0.4.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 (55) hide show
  1. package/README.md +26 -28
  2. package/dist/cli.js +18 -30
  3. package/dist/client/index.js +1 -1
  4. package/dist/commands/run.js +34 -9
  5. package/dist/commands/tdd.js +6 -1
  6. package/dist/commands/upload.js +52 -3
  7. package/dist/server/handlers/api-handler.js +83 -0
  8. package/dist/server/handlers/tdd-handler.js +138 -0
  9. package/dist/server/http-server.js +132 -0
  10. package/dist/services/api-service.js +40 -11
  11. package/dist/services/server-manager.js +45 -29
  12. package/dist/services/test-runner.js +64 -69
  13. package/dist/services/uploader.js +47 -82
  14. package/dist/types/commands/run.d.ts +4 -1
  15. package/dist/types/commands/tdd.d.ts +4 -1
  16. package/dist/types/sdk/index.d.ts +6 -6
  17. package/dist/types/server/handlers/api-handler.d.ts +49 -0
  18. package/dist/types/server/handlers/tdd-handler.d.ts +85 -0
  19. package/dist/types/server/http-server.d.ts +5 -0
  20. package/dist/types/services/api-service.d.ts +4 -2
  21. package/dist/types/services/server-manager.d.ts +148 -3
  22. package/dist/types/services/test-runner.d.ts +1 -0
  23. package/dist/types/utils/config-helpers.d.ts +1 -1
  24. package/dist/types/utils/console-ui.d.ts +1 -1
  25. package/dist/utils/console-ui.js +4 -14
  26. package/docs/api-reference.md +2 -5
  27. package/docs/getting-started.md +1 -1
  28. package/docs/tdd-mode.md +9 -9
  29. package/docs/test-integration.md +3 -17
  30. package/docs/upload-command.md +7 -0
  31. package/package.json +1 -1
  32. package/dist/screenshot-wrapper.js +0 -68
  33. package/dist/server/index.js +0 -522
  34. package/dist/services/service-utils.js +0 -171
  35. package/dist/types/index.js +0 -153
  36. package/dist/types/screenshot-wrapper.d.ts +0 -27
  37. package/dist/types/server/index.d.ts +0 -38
  38. package/dist/types/services/service-utils.d.ts +0 -45
  39. package/dist/types/types/index.d.ts +0 -373
  40. package/dist/types/utils/diagnostics.d.ts +0 -69
  41. package/dist/types/utils/error-messages.d.ts +0 -42
  42. package/dist/types/utils/framework-detector.d.ts +0 -5
  43. package/dist/types/utils/help.d.ts +0 -11
  44. package/dist/types/utils/image-comparison.d.ts +0 -42
  45. package/dist/types/utils/package.d.ts +0 -1
  46. package/dist/types/utils/project-detection.d.ts +0 -19
  47. package/dist/types/utils/ui-helpers.d.ts +0 -23
  48. package/dist/utils/diagnostics.js +0 -184
  49. package/dist/utils/error-messages.js +0 -34
  50. package/dist/utils/framework-detector.js +0 -40
  51. package/dist/utils/help.js +0 -66
  52. package/dist/utils/image-comparison.js +0 -172
  53. package/dist/utils/package.js +0 -9
  54. package/dist/utils/project-detection.js +0 -145
  55. package/dist/utils/ui-helpers.js +0 -86
@@ -158,11 +158,12 @@ export class ConsoleUI {
158
158
  startSpinner(message) {
159
159
  if (this.json || !process.stdout.isTTY) return;
160
160
  this.stopSpinner();
161
+ this.currentMessage = message;
161
162
  const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
162
163
  let i = 0;
163
164
  this.spinner = setInterval(() => {
164
165
  const frame = frames[i++ % frames.length];
165
- const line = `${this.colors.blue(frame)} ${message}`;
166
+ const line = `${this.colors.blue(frame)} ${this.currentMessage || message}`;
166
167
 
167
168
  // Clear previous line and write new one
168
169
  process.stdout.write('\r' + ' '.repeat(this.lastLine.length) + '\r');
@@ -211,16 +212,5 @@ export class ConsoleUI {
211
212
  }
212
213
  }
213
214
 
214
- // Ensure spinner is cleaned up on process exit
215
- process.on('exit', () => {
216
- // Clear any remaining spinner
217
- if (process.stdout.isTTY) {
218
- process.stdout.write('\r' + ' '.repeat(80) + '\r');
219
- }
220
- });
221
- process.on('SIGINT', () => {
222
- if (process.stdout.isTTY) {
223
- process.stdout.write('\r' + ' '.repeat(80) + '\r');
224
- }
225
- process.exit(1);
226
- });
215
+ // Note: Global process event listeners are handled in individual commands
216
+ // to avoid interference between tests and proper cleanup
@@ -288,6 +288,7 @@ Upload screenshots from a directory.
288
288
  - `--threshold <number>` - Comparison threshold (0-1)
289
289
  - `--token <token>` - API token override
290
290
  - `--wait` - Wait for build completion
291
+ - `--upload-all` - Upload all screenshots without SHA deduplication
291
292
 
292
293
  **Exit Codes:**
293
294
  - `0` - Success (all approved or no changes)
@@ -316,18 +317,14 @@ Run tests with Vizzly integration.
316
317
 
317
318
  *Processing Options:*
318
319
  - `--wait` - Wait for build completion and exit with appropriate code
319
- - `--eager` - Create build immediately (default: lazy creation)
320
320
  - `--threshold <number>` - Comparison threshold (0-1, default: 0.01)
321
321
  - `--upload-timeout <ms>` - Upload wait timeout in ms (default: from config or 30000)
322
+ - `--upload-all` - Upload all screenshots without SHA deduplication
322
323
 
323
324
  *Development & Testing:*
324
- - `--tdd` - Enable TDD mode with local comparisons
325
325
  - `--allow-no-token` - Allow running without API token
326
326
  - `--token <token>` - API token override
327
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
328
 
332
329
  **Environment Variables Set:**
333
330
  - `VIZZLY_SERVER_URL` - Local server URL
@@ -59,7 +59,7 @@ npx vizzly upload ./screenshots --build-name "Release v1.2.3"
59
59
  npx vizzly run "npm test"
60
60
 
61
61
  # Use TDD mode for local development
62
- npx vizzly run "npm test" --tdd
62
+ npx vizzly tdd "npm test"
63
63
  ```
64
64
 
65
65
  ### 6. In your test code
package/docs/tdd-mode.md CHANGED
@@ -145,11 +145,11 @@ vizzly tdd "npm test" --timeout 60000
145
145
  npx vizzly run "npm test" --wait
146
146
 
147
147
  # 2. Start TDD development
148
- npx vizzly run "npm test" --tdd
148
+ npx vizzly tdd "npm test"
149
149
 
150
150
  # 3. Make changes and iterate
151
151
  # Edit code...
152
- npx vizzly run "npm test" --tdd
152
+ npx vizzly tdd "npm test"
153
153
 
154
154
  # 4. Upload when satisfied
155
155
  npx vizzly run "npm test" --wait
@@ -159,13 +159,13 @@ npx vizzly run "npm test" --wait
159
159
 
160
160
  ```bash
161
161
  # Start with latest baselines
162
- npx vizzly run "npm test" --tdd
162
+ npx vizzly tdd "npm test"
163
163
 
164
164
  # Develop new feature with immediate feedback
165
165
  while [ $? -ne 0 ]; do
166
166
  # Edit code to fix visual differences
167
167
  vim src/components/NewFeature.js
168
- npx vizzly run "npm test" --tdd
168
+ npx vizzly tdd "npm test"
169
169
  done
170
170
 
171
171
  # Upload completed feature
@@ -176,7 +176,7 @@ npx vizzly run "npm test" --build-name "Feature: New Dashboard"
176
176
 
177
177
  ```bash
178
178
  # Use TDD mode to verify fixes
179
- npx vizzly run "npm test" --tdd
179
+ npx vizzly tdd "npm test"
180
180
 
181
181
  # Tests should pass when bug is fixed
182
182
  # Then upload the fix
@@ -216,7 +216,7 @@ npx vizzly status # Shows latest build info
216
216
  Download new baselines from a different build:
217
217
 
218
218
  ```bash
219
- npx vizzly run "npm test" --tdd --baseline-build build-xyz789
219
+ npx vizzly tdd "npm test" --baseline-build build-xyz789
220
220
  ```
221
221
 
222
222
  ### Force Baseline Refresh
@@ -225,7 +225,7 @@ Delete local baselines to force re-download:
225
225
 
226
226
  ```bash
227
227
  rm -rf .vizzly/baselines/
228
- npx vizzly run "npm test" --tdd
228
+ npx vizzly tdd "npm test"
229
229
  ```
230
230
 
231
231
  ## Advanced Usage
@@ -276,7 +276,7 @@ jobs:
276
276
  # Use TDD mode for PR builds (faster, no uploads)
277
277
  - name: TDD Visual Tests (PR)
278
278
  if: github.event_name == 'pull_request'
279
- run: npx vizzly run "npm test" --tdd
279
+ run: npx vizzly tdd "npm test"
280
280
  env:
281
281
  VIZZLY_TOKEN: ${{ secrets.VIZZLY_TOKEN }}
282
282
 
@@ -337,7 +337,7 @@ Error: Failed to compare 'homepage': baseline image not found
337
337
  **Solution**: Refresh baselines:
338
338
  ```bash
339
339
  rm -rf .vizzly/baselines/
340
- npx vizzly run "npm test" --tdd
340
+ npx vizzly tdd "npm test"
341
341
  ```
342
342
 
343
343
  ### Odiff Not Found
@@ -199,9 +199,9 @@ vizzly run "npm test" --branch "feature/new-ui"
199
199
  vizzly run "npm test" --wait
200
200
  ```
201
201
 
202
- **`--eager`** - Create build immediately (default: lazy)
202
+ **`--upload-all`** - Upload all screenshots without SHA deduplication
203
203
  ```bash
204
- vizzly run "npm test" --eager
204
+ vizzly run "npm test" --upload-all
205
205
  ```
206
206
 
207
207
  **`--threshold <number>`** - Comparison threshold (0-1, default: 0.01)
@@ -211,10 +211,7 @@ vizzly run "npm test" --threshold 0.02
211
211
 
212
212
  ### Development Options
213
213
 
214
- **`--tdd`** - Enable TDD mode (see [TDD Mode Guide](./tdd-mode.md))
215
- ```bash
216
- vizzly run "npm test" --tdd
217
- ```
214
+ For TDD mode, use the dedicated `vizzly tdd` command. See [TDD Mode Guide](./tdd-mode.md) for details.
218
215
 
219
216
  **`--allow-no-token`** - Allow running without API token
220
217
  ```bash
@@ -226,17 +223,6 @@ vizzly run "npm test" --allow-no-token
226
223
  vizzly run "npm test" --token "your-token-here"
227
224
  ```
228
225
 
229
- ### Baseline Configuration
230
-
231
- **`--baseline-build <id>`** - Use specific build as baseline
232
- ```bash
233
- vizzly run "npm test" --baseline-build "build_123"
234
- ```
235
-
236
- **`--baseline-comparison <id>`** - Use specific comparison as baseline
237
- ```bash
238
- vizzly run "npm test" --baseline-comparison "comp_456"
239
- ```
240
226
 
241
227
  ## Screenshot Properties
242
228
 
@@ -72,6 +72,13 @@ This will:
72
72
  - Show progress and results
73
73
  - Exit with appropriate status code
74
74
 
75
+ **`--upload-all`** - Upload all screenshots without SHA deduplication
76
+ ```bash
77
+ vizzly upload ./screenshots --upload-all
78
+ ```
79
+
80
+ By default, Vizzly deduplicates screenshots based on their SHA hash to avoid unnecessary uploads. Use this flag to force upload of all screenshots regardless of their content.
81
+
75
82
  **`--metadata <json>`** - Additional metadata as JSON
76
83
  ```bash
77
84
  vizzly upload ./screenshots --metadata '{"browser": "chrome", "viewport": "1920x1080"}'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly-testing/cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Visual review platform for UI developers and designers",
5
5
  "keywords": [
6
6
  "visual-testing",
@@ -1,68 +0,0 @@
1
- /**
2
- * Simple factory for creating Vizzly instances with shared configuration
3
- * Users handle their own screenshots, just pass the buffer to Vizzly
4
- */
5
-
6
- import { createVizzly as createVizzlySDK } from './vizzly.js';
7
-
8
- /**
9
- * Create a factory that pre-configures Vizzly instances
10
- *
11
- * @param {Object} config - Shared configuration
12
- * @param {Object} [config.defaultProperties] - Default metadata for all screenshots
13
- * @param {number} [config.defaultThreshold] - Default comparison threshold
14
- *
15
- * @example
16
- * // test-setup.js - Configure once
17
- * export const createVizzly = vizzlyFactory({
18
- * defaultProperties: {
19
- * framework: 'playwright',
20
- * project: 'web-app'
21
- * }
22
- * });
23
- *
24
- * // my-test.spec.js - Use everywhere
25
- * const vizzly = createVizzly();
26
- *
27
- * const screenshot = await page.screenshot({ fullPage: true }); // Your method
28
- * await vizzly.screenshot({
29
- * name: 'homepage',
30
- * image: screenshot, // Your buffer
31
- * properties: { browser: 'chrome' } // Merges with defaults
32
- * });
33
- */
34
- export function vizzlyFactory(globalConfig) {
35
- const {
36
- defaultProperties = {},
37
- defaultThreshold,
38
- ...vizzlyConfig
39
- } = globalConfig;
40
- return function createVizzly(overrideConfig = {}) {
41
- const vizzly = createVizzlySDK({
42
- ...vizzlyConfig,
43
- ...overrideConfig
44
- });
45
- return {
46
- ...vizzly,
47
- /**
48
- * Take a screenshot with default properties merged in
49
- *
50
- * @param {Object} screenshot - Screenshot object
51
- * @param {string} screenshot.name - Screenshot name
52
- * @param {Buffer} screenshot.image - Image buffer from YOUR screenshot method
53
- * @param {Object} [screenshot.properties] - Additional metadata (merged with defaults)
54
- * @param {number} [screenshot.threshold] - Comparison threshold (defaults to global)
55
- */
56
- async screenshot(screenshot) {
57
- return await vizzly.screenshot({
58
- ...screenshot,
59
- properties: {
60
- ...defaultProperties,
61
- ...screenshot.properties
62
- },
63
- threshold: screenshot.threshold || defaultThreshold
64
- });
65
- }
66
- };
67
- };
68
- }