@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.
- package/README.md +26 -28
- package/dist/cli.js +18 -30
- package/dist/client/index.js +1 -1
- package/dist/commands/run.js +34 -9
- package/dist/commands/tdd.js +6 -1
- package/dist/commands/upload.js +52 -3
- package/dist/server/handlers/api-handler.js +83 -0
- package/dist/server/handlers/tdd-handler.js +138 -0
- package/dist/server/http-server.js +132 -0
- package/dist/services/api-service.js +40 -11
- package/dist/services/server-manager.js +45 -29
- package/dist/services/test-runner.js +64 -69
- package/dist/services/uploader.js +47 -82
- package/dist/types/commands/run.d.ts +4 -1
- package/dist/types/commands/tdd.d.ts +4 -1
- package/dist/types/sdk/index.d.ts +6 -6
- package/dist/types/server/handlers/api-handler.d.ts +49 -0
- package/dist/types/server/handlers/tdd-handler.d.ts +85 -0
- package/dist/types/server/http-server.d.ts +5 -0
- package/dist/types/services/api-service.d.ts +4 -2
- package/dist/types/services/server-manager.d.ts +148 -3
- package/dist/types/services/test-runner.d.ts +1 -0
- package/dist/types/utils/config-helpers.d.ts +1 -1
- package/dist/types/utils/console-ui.d.ts +1 -1
- package/dist/utils/console-ui.js +4 -14
- package/docs/api-reference.md +2 -5
- package/docs/getting-started.md +1 -1
- package/docs/tdd-mode.md +9 -9
- package/docs/test-integration.md +3 -17
- package/docs/upload-command.md +7 -0
- package/package.json +1 -1
- package/dist/screenshot-wrapper.js +0 -68
- package/dist/server/index.js +0 -522
- package/dist/services/service-utils.js +0 -171
- package/dist/types/index.js +0 -153
- package/dist/types/screenshot-wrapper.d.ts +0 -27
- package/dist/types/server/index.d.ts +0 -38
- package/dist/types/services/service-utils.d.ts +0 -45
- package/dist/types/types/index.d.ts +0 -373
- package/dist/types/utils/diagnostics.d.ts +0 -69
- package/dist/types/utils/error-messages.d.ts +0 -42
- package/dist/types/utils/framework-detector.d.ts +0 -5
- package/dist/types/utils/help.d.ts +0 -11
- package/dist/types/utils/image-comparison.d.ts +0 -42
- package/dist/types/utils/package.d.ts +0 -1
- package/dist/types/utils/project-detection.d.ts +0 -19
- package/dist/types/utils/ui-helpers.d.ts +0 -23
- package/dist/utils/diagnostics.js +0 -184
- package/dist/utils/error-messages.js +0 -34
- package/dist/utils/framework-detector.js +0 -40
- package/dist/utils/help.js +0 -66
- package/dist/utils/image-comparison.js +0 -172
- package/dist/utils/package.js +0 -9
- package/dist/utils/project-detection.js +0 -145
- package/dist/utils/ui-helpers.js +0 -86
package/dist/utils/console-ui.js
CHANGED
|
@@ -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
|
-
//
|
|
215
|
-
|
|
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
|
package/docs/api-reference.md
CHANGED
|
@@ -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
|
package/docs/getting-started.md
CHANGED
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
|
|
148
|
+
npx vizzly tdd "npm test"
|
|
149
149
|
|
|
150
150
|
# 3. Make changes and iterate
|
|
151
151
|
# Edit code...
|
|
152
|
-
npx vizzly
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
340
|
+
npx vizzly tdd "npm test"
|
|
341
341
|
```
|
|
342
342
|
|
|
343
343
|
### Odiff Not Found
|
package/docs/test-integration.md
CHANGED
|
@@ -199,9 +199,9 @@ vizzly run "npm test" --branch "feature/new-ui"
|
|
|
199
199
|
vizzly run "npm test" --wait
|
|
200
200
|
```
|
|
201
201
|
|
|
202
|
-
**`--
|
|
202
|
+
**`--upload-all`** - Upload all screenshots without SHA deduplication
|
|
203
203
|
```bash
|
|
204
|
-
vizzly run "npm test" --
|
|
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
|
-
|
|
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
|
|
package/docs/upload-command.md
CHANGED
|
@@ -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,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
|
-
}
|