@vizzly-testing/cli 0.16.0 → 0.16.2
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/dist/client/index.js +21 -4
- package/dist/reporter/reporter-bundle.css +1 -1
- package/dist/reporter/reporter-bundle.iife.js +14 -14
- package/dist/sdk/index.js +6 -6
- package/dist/server/handlers/tdd-handler.js +13 -6
- package/dist/services/test-runner.js +0 -8
- package/dist/services/uploader.js +1 -1
- package/dist/types/client.d.ts +88 -0
- package/dist/types/config.d.ts +29 -0
- package/dist/types/index.d.ts +426 -9
- package/dist/types/sdk.d.ts +146 -0
- package/dist/utils/config-helpers.js +2 -2
- package/package.json +24 -7
- package/dist/types/cli.d.ts +0 -2
- package/dist/types/client/index.d.ts +0 -80
- package/dist/types/commands/doctor.d.ts +0 -11
- package/dist/types/commands/finalize.d.ts +0 -13
- package/dist/types/commands/init.d.ts +0 -32
- package/dist/types/commands/login.d.ts +0 -11
- package/dist/types/commands/logout.d.ts +0 -11
- package/dist/types/commands/project.d.ts +0 -28
- package/dist/types/commands/run.d.ts +0 -16
- package/dist/types/commands/status.d.ts +0 -13
- package/dist/types/commands/tdd-daemon.d.ts +0 -24
- package/dist/types/commands/tdd.d.ts +0 -17
- package/dist/types/commands/upload.d.ts +0 -13
- package/dist/types/commands/whoami.d.ts +0 -11
- package/dist/types/errors/vizzly-error.d.ts +0 -75
- package/dist/types/plugin-loader.d.ts +0 -7
- package/dist/types/reporter/src/api/client.d.ts +0 -178
- package/dist/types/reporter/src/components/app-router.d.ts +0 -1
- package/dist/types/reporter/src/components/code-block.d.ts +0 -4
- package/dist/types/reporter/src/components/comparison/comparison-actions.d.ts +0 -5
- package/dist/types/reporter/src/components/comparison/comparison-card.d.ts +0 -7
- package/dist/types/reporter/src/components/comparison/comparison-group.d.ts +0 -10
- package/dist/types/reporter/src/components/comparison/comparison-list.d.ts +0 -6
- package/dist/types/reporter/src/components/comparison/comparison-modes/onion-skin-mode.d.ts +0 -10
- package/dist/types/reporter/src/components/comparison/comparison-modes/overlay-mode.d.ts +0 -11
- package/dist/types/reporter/src/components/comparison/comparison-modes/shared/base-comparison-mode.d.ts +0 -14
- package/dist/types/reporter/src/components/comparison/comparison-modes/shared/image-renderer.d.ts +0 -30
- package/dist/types/reporter/src/components/comparison/comparison-modes/toggle-view.d.ts +0 -8
- package/dist/types/reporter/src/components/comparison/comparison-viewer.d.ts +0 -8
- package/dist/types/reporter/src/components/comparison/fullscreen-viewer.d.ts +0 -13
- package/dist/types/reporter/src/components/comparison/screenshot-display.d.ts +0 -16
- package/dist/types/reporter/src/components/comparison/screenshot-list.d.ts +0 -9
- package/dist/types/reporter/src/components/comparison/variant-selector.d.ts +0 -9
- package/dist/types/reporter/src/components/comparison/view-mode-selector.d.ts +0 -4
- package/dist/types/reporter/src/components/dashboard/dashboard-filters.d.ts +0 -16
- package/dist/types/reporter/src/components/design-system/alert.d.ts +0 -9
- package/dist/types/reporter/src/components/design-system/badge.d.ts +0 -17
- package/dist/types/reporter/src/components/design-system/button.d.ts +0 -19
- package/dist/types/reporter/src/components/design-system/card.d.ts +0 -31
- package/dist/types/reporter/src/components/design-system/empty-state.d.ts +0 -13
- package/dist/types/reporter/src/components/design-system/form-controls.d.ts +0 -44
- package/dist/types/reporter/src/components/design-system/health-ring.d.ts +0 -7
- package/dist/types/reporter/src/components/design-system/index.d.ts +0 -11
- package/dist/types/reporter/src/components/design-system/modal.d.ts +0 -10
- package/dist/types/reporter/src/components/design-system/skeleton.d.ts +0 -19
- package/dist/types/reporter/src/components/design-system/spinner.d.ts +0 -10
- package/dist/types/reporter/src/components/design-system/tabs.d.ts +0 -13
- package/dist/types/reporter/src/components/layout/header.d.ts +0 -5
- package/dist/types/reporter/src/components/layout/index.d.ts +0 -2
- package/dist/types/reporter/src/components/layout/layout.d.ts +0 -6
- package/dist/types/reporter/src/components/ui/smart-image.d.ts +0 -7
- package/dist/types/reporter/src/components/ui/toast.d.ts +0 -4
- package/dist/types/reporter/src/components/views/builds-view.d.ts +0 -1
- package/dist/types/reporter/src/components/views/comparison-detail-view.d.ts +0 -5
- package/dist/types/reporter/src/components/views/comparisons-view.d.ts +0 -5
- package/dist/types/reporter/src/components/views/projects-view.d.ts +0 -1
- package/dist/types/reporter/src/components/views/settings-view.d.ts +0 -1
- package/dist/types/reporter/src/components/views/stats-view.d.ts +0 -1
- package/dist/types/reporter/src/components/waiting-for-screenshots.d.ts +0 -1
- package/dist/types/reporter/src/hooks/queries/use-auth-queries.d.ts +0 -15
- package/dist/types/reporter/src/hooks/queries/use-cloud-queries.d.ts +0 -6
- package/dist/types/reporter/src/hooks/queries/use-config-queries.d.ts +0 -6
- package/dist/types/reporter/src/hooks/queries/use-tdd-queries.d.ts +0 -9
- package/dist/types/reporter/src/hooks/use-comparison-filters.d.ts +0 -20
- package/dist/types/reporter/src/hooks/use-image-loader.d.ts +0 -1
- package/dist/types/reporter/src/lib/query-client.d.ts +0 -2
- package/dist/types/reporter/src/lib/query-keys.d.ts +0 -13
- package/dist/types/reporter/src/main.d.ts +0 -1
- package/dist/types/reporter/src/services/api-client.d.ts +0 -11
- package/dist/types/reporter/src/utils/comparison-helpers.d.ts +0 -16
- package/dist/types/reporter/src/utils/constants.d.ts +0 -37
- package/dist/types/reporter/vite.config.d.ts +0 -2
- package/dist/types/reporter/vite.dev.config.d.ts +0 -2
- package/dist/types/sdk/index.d.ts +0 -110
- package/dist/types/server/handlers/api-handler.d.ts +0 -88
- package/dist/types/server/handlers/tdd-handler.d.ts +0 -162
- package/dist/types/server/http-server.d.ts +0 -6
- package/dist/types/server/middleware/cors.d.ts +0 -11
- package/dist/types/server/middleware/json-parser.d.ts +0 -10
- package/dist/types/server/middleware/response.d.ts +0 -50
- package/dist/types/server/routers/assets.d.ts +0 -6
- package/dist/types/server/routers/auth.d.ts +0 -9
- package/dist/types/server/routers/baseline.d.ts +0 -13
- package/dist/types/server/routers/cloud-proxy.d.ts +0 -11
- package/dist/types/server/routers/config.d.ts +0 -9
- package/dist/types/server/routers/dashboard.d.ts +0 -6
- package/dist/types/server/routers/health.d.ts +0 -11
- package/dist/types/server/routers/projects.d.ts +0 -9
- package/dist/types/server/routers/screenshot.d.ts +0 -11
- package/dist/types/services/api-service.d.ts +0 -121
- package/dist/types/services/auth-service.d.ts +0 -59
- package/dist/types/services/build-manager.d.ts +0 -69
- package/dist/types/services/config-service.d.ts +0 -97
- package/dist/types/services/html-report-generator.d.ts +0 -52
- package/dist/types/services/index.d.ts +0 -7
- package/dist/types/services/project-service.d.ts +0 -105
- package/dist/types/services/report-generator/viewer.d.ts +0 -0
- package/dist/types/services/screenshot-server.d.ts +0 -10
- package/dist/types/services/server-manager.d.ts +0 -269
- package/dist/types/services/static-report-generator.d.ts +0 -25
- package/dist/types/services/tdd-service.d.ts +0 -122
- package/dist/types/services/test-runner.d.ts +0 -31
- package/dist/types/services/uploader.d.ts +0 -36
- package/dist/types/utils/browser.d.ts +0 -6
- package/dist/types/utils/build-history.d.ts +0 -16
- package/dist/types/utils/ci-env.d.ts +0 -55
- package/dist/types/utils/colors.d.ts +0 -12
- package/dist/types/utils/config-helpers.d.ts +0 -6
- package/dist/types/utils/config-loader.d.ts +0 -25
- package/dist/types/utils/config-schema.d.ts +0 -51
- package/dist/types/utils/environment-config.d.ts +0 -59
- package/dist/types/utils/environment.d.ts +0 -36
- package/dist/types/utils/fetch-utils.d.ts +0 -1
- package/dist/types/utils/file-helpers.d.ts +0 -18
- package/dist/types/utils/git.d.ts +0 -56
- package/dist/types/utils/global-config.d.ts +0 -84
- package/dist/types/utils/image-input-detector.d.ts +0 -71
- package/dist/types/utils/output.d.ts +0 -84
- package/dist/types/utils/package-info.d.ts +0 -15
- package/dist/types/utils/security.d.ts +0 -30
package/dist/sdk/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import { VizzlyError } from '../errors/vizzly-error.js';
|
|
|
22
22
|
/**
|
|
23
23
|
* Create a new Vizzly instance with custom configuration
|
|
24
24
|
*
|
|
25
|
-
* @param {
|
|
25
|
+
* @param {Object} [config] - Configuration options
|
|
26
26
|
* @returns {Promise<VizzlySDK>} Configured Vizzly SDK instance
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
@@ -147,7 +147,7 @@ export function createVizzly(config = {}, options = {}) {
|
|
|
147
147
|
*/
|
|
148
148
|
export class VizzlySDK extends EventEmitter {
|
|
149
149
|
/**
|
|
150
|
-
* @param {
|
|
150
|
+
* @param {Object} config - Configuration
|
|
151
151
|
* @param {Object} services - Service instances
|
|
152
152
|
*/
|
|
153
153
|
constructor(config, services) {
|
|
@@ -223,7 +223,7 @@ export class VizzlySDK extends EventEmitter {
|
|
|
223
223
|
* Capture a screenshot
|
|
224
224
|
* @param {string} name - Screenshot name
|
|
225
225
|
* @param {Buffer|string} imageBuffer - Image data as a Buffer, or a file path to an image
|
|
226
|
-
* @param {
|
|
226
|
+
* @param {Object} [options] - Options
|
|
227
227
|
* @returns {Promise<void>}
|
|
228
228
|
* @throws {VizzlyError} When server is not running
|
|
229
229
|
* @throws {VizzlyError} When file path is provided but file doesn't exist
|
|
@@ -288,8 +288,8 @@ export class VizzlySDK extends EventEmitter {
|
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
290
|
* Upload all captured screenshots
|
|
291
|
-
* @param {
|
|
292
|
-
* @returns {Promise<
|
|
291
|
+
* @param {Object} [options] - Upload options
|
|
292
|
+
* @returns {Promise<Object>} Upload result
|
|
293
293
|
*/
|
|
294
294
|
async upload(options = {}) {
|
|
295
295
|
if (!this.services?.uploader) {
|
|
@@ -332,7 +332,7 @@ export class VizzlySDK extends EventEmitter {
|
|
|
332
332
|
* Run local comparison in TDD mode
|
|
333
333
|
* @param {string} name - Screenshot name
|
|
334
334
|
* @param {Buffer|string} imageBuffer - Current image as a Buffer, or a file path to an image
|
|
335
|
-
* @returns {Promise<
|
|
335
|
+
* @returns {Promise<Object>} Comparison result
|
|
336
336
|
* @throws {VizzlyError} When file path is provided but file doesn't exist
|
|
337
337
|
* @throws {VizzlyError} When file cannot be read due to permissions or I/O errors
|
|
338
338
|
*/
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import { writeFileSync, readFileSync, existsSync } from 'fs';
|
|
3
3
|
import { join, resolve } from 'path';
|
|
4
|
-
import
|
|
4
|
+
import { getDimensionsSync } from '@vizzly-testing/honeydiff';
|
|
5
5
|
import * as output from '../../utils/output.js';
|
|
6
6
|
import { TddService } from '../../services/tdd-service.js';
|
|
7
7
|
import { sanitizeScreenshotName, validateScreenshotProperties } from '../../utils/security.js';
|
|
8
8
|
import { detectImageInputType } from '../../utils/image-input-detector.js';
|
|
9
|
-
let {
|
|
10
|
-
getDimensionsSync
|
|
11
|
-
} = honeydiff;
|
|
12
9
|
|
|
13
10
|
/**
|
|
14
11
|
* Group comparisons by screenshot name with variant structure
|
|
@@ -142,9 +139,19 @@ export const createTddHandler = (config, workingDir, baselineBuild, baselineComp
|
|
|
142
139
|
// This ensures we update the correct variant even with same name
|
|
143
140
|
const existingIndex = reportData.comparisons.findIndex(c => c.id === newComparison.id);
|
|
144
141
|
if (existingIndex >= 0) {
|
|
145
|
-
|
|
142
|
+
// Preserve initialStatus from the original comparison
|
|
143
|
+
// This keeps sort order stable when status changes (e.g., after approval)
|
|
144
|
+
let initialStatus = reportData.comparisons[existingIndex].initialStatus;
|
|
145
|
+
reportData.comparisons[existingIndex] = {
|
|
146
|
+
...newComparison,
|
|
147
|
+
initialStatus: initialStatus || newComparison.status
|
|
148
|
+
};
|
|
146
149
|
} else {
|
|
147
|
-
|
|
150
|
+
// New comparison - set initialStatus to current status
|
|
151
|
+
reportData.comparisons.push({
|
|
152
|
+
...newComparison,
|
|
153
|
+
initialStatus: newComparison.status
|
|
154
|
+
});
|
|
148
155
|
}
|
|
149
156
|
|
|
150
157
|
// Generate grouped structure from flat comparisons
|
|
@@ -94,14 +94,6 @@ export class TestRunner extends EventEmitter {
|
|
|
94
94
|
|
|
95
95
|
// Start server with appropriate handler
|
|
96
96
|
await this.serverManager.start(buildId, tdd, options.setBaseline);
|
|
97
|
-
|
|
98
|
-
// Forward server events
|
|
99
|
-
if (this.serverManager.server?.emitter) {
|
|
100
|
-
this.serverManager.server.emitter.on('screenshot-captured', screenshotInfo => {
|
|
101
|
-
screenshotCount++;
|
|
102
|
-
this.emit('screenshot-captured', screenshotInfo);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
97
|
const env = {
|
|
106
98
|
...process.env,
|
|
107
99
|
VIZZLY_SERVER_URL: `http://localhost:${this.config.server.port}`,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vizzly Client Type Definitions
|
|
3
|
+
* Lightweight client for test runners
|
|
4
|
+
* @module @vizzly-testing/cli/client
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Take a screenshot for visual regression testing
|
|
9
|
+
*
|
|
10
|
+
* @param name - Unique name for the screenshot
|
|
11
|
+
* @param imageBuffer - PNG image data as a Buffer, or a file path to an image
|
|
12
|
+
* @param options - Optional configuration
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Basic usage with Buffer
|
|
16
|
+
* import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
|
|
17
|
+
*
|
|
18
|
+
* const screenshot = await page.screenshot();
|
|
19
|
+
* await vizzlyScreenshot('homepage', screenshot);
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Basic usage with file path
|
|
23
|
+
* await vizzlyScreenshot('homepage', './screenshots/homepage.png');
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // With properties and threshold
|
|
27
|
+
* await vizzlyScreenshot('checkout-form', screenshot, {
|
|
28
|
+
* properties: { browser: 'chrome', viewport: '1920x1080' },
|
|
29
|
+
* threshold: 5
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
export function vizzlyScreenshot(
|
|
33
|
+
name: string,
|
|
34
|
+
imageBuffer: Buffer | string,
|
|
35
|
+
options?: {
|
|
36
|
+
properties?: Record<string, unknown>;
|
|
37
|
+
threshold?: number;
|
|
38
|
+
fullPage?: boolean;
|
|
39
|
+
}
|
|
40
|
+
): Promise<void>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Wait for all queued screenshots to be processed
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* afterAll(async () => {
|
|
47
|
+
* await vizzlyFlush();
|
|
48
|
+
* });
|
|
49
|
+
*/
|
|
50
|
+
export function vizzlyFlush(): Promise<void>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Check if the Vizzly client is initialized and ready
|
|
54
|
+
*
|
|
55
|
+
* @returns True if client is ready, false otherwise
|
|
56
|
+
*/
|
|
57
|
+
export function isVizzlyReady(): boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Configure the client with custom settings
|
|
61
|
+
*
|
|
62
|
+
* @param config - Configuration options
|
|
63
|
+
*/
|
|
64
|
+
export function configure(config?: {
|
|
65
|
+
serverUrl?: string;
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
}): void;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Enable or disable screenshot capture
|
|
71
|
+
*
|
|
72
|
+
* @param enabled - Whether to enable screenshots
|
|
73
|
+
*/
|
|
74
|
+
export function setEnabled(enabled: boolean): void;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get information about Vizzly client state
|
|
78
|
+
*
|
|
79
|
+
* @returns Client information
|
|
80
|
+
*/
|
|
81
|
+
export function getVizzlyInfo(): {
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
serverUrl: string | null;
|
|
84
|
+
ready: boolean;
|
|
85
|
+
buildId: string | null;
|
|
86
|
+
tddMode: boolean;
|
|
87
|
+
disabled: boolean;
|
|
88
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vizzly Config Type Definitions
|
|
3
|
+
* Configuration helpers
|
|
4
|
+
* @module @vizzly-testing/cli/config
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { VizzlyConfig } from './index';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Define Vizzly configuration with type hints
|
|
11
|
+
*
|
|
12
|
+
* Use this in your vizzly.config.js for better IDE support:
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { defineConfig } from '@vizzly-testing/cli/config';
|
|
16
|
+
*
|
|
17
|
+
* export default defineConfig({
|
|
18
|
+
* apiKey: process.env.VIZZLY_TOKEN,
|
|
19
|
+
* server: {
|
|
20
|
+
* port: 47392
|
|
21
|
+
* },
|
|
22
|
+
* comparison: {
|
|
23
|
+
* threshold: 0.1
|
|
24
|
+
* }
|
|
25
|
+
* });
|
|
26
|
+
*/
|
|
27
|
+
export function defineConfig(
|
|
28
|
+
config: import('./index').VizzlyConfig
|
|
29
|
+
): import('./index').VizzlyConfig;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,426 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Vizzly CLI Type Definitions
|
|
3
|
+
* @module @vizzly-testing/cli
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { EventEmitter } from 'events';
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Configuration Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
export interface ServerConfig {
|
|
13
|
+
port?: number;
|
|
14
|
+
timeout?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface BuildConfig {
|
|
18
|
+
name?: string;
|
|
19
|
+
environment?: string;
|
|
20
|
+
branch?: string;
|
|
21
|
+
commit?: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface UploadConfig {
|
|
26
|
+
screenshotsDir?: string | string[];
|
|
27
|
+
batchSize?: number;
|
|
28
|
+
timeout?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ComparisonConfig {
|
|
32
|
+
threshold?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface TddConfig {
|
|
36
|
+
openReport?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface VizzlyConfig {
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
apiUrl?: string;
|
|
42
|
+
server?: ServerConfig;
|
|
43
|
+
build?: BuildConfig;
|
|
44
|
+
upload?: UploadConfig;
|
|
45
|
+
comparison?: ComparisonConfig;
|
|
46
|
+
tdd?: TddConfig;
|
|
47
|
+
plugins?: string[];
|
|
48
|
+
parallelId?: string;
|
|
49
|
+
baselineBuildId?: string;
|
|
50
|
+
baselineComparisonId?: string;
|
|
51
|
+
eager?: boolean;
|
|
52
|
+
wait?: boolean;
|
|
53
|
+
allowNoToken?: boolean;
|
|
54
|
+
/** Allow additional plugin-specific configuration */
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// Screenshot Types
|
|
60
|
+
// ============================================================================
|
|
61
|
+
|
|
62
|
+
export interface ScreenshotOptions {
|
|
63
|
+
properties?: Record<string, unknown>;
|
|
64
|
+
threshold?: number;
|
|
65
|
+
fullPage?: boolean;
|
|
66
|
+
buildId?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ScreenshotResult {
|
|
70
|
+
success: boolean;
|
|
71
|
+
status?: 'passed' | 'failed' | 'new';
|
|
72
|
+
name?: string;
|
|
73
|
+
diffPercentage?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// Comparison Types
|
|
78
|
+
// ============================================================================
|
|
79
|
+
|
|
80
|
+
export interface ComparisonResult {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
status: 'passed' | 'failed' | 'new' | 'error' | 'baseline-updated';
|
|
84
|
+
baseline: string;
|
|
85
|
+
current: string;
|
|
86
|
+
diff: string | null;
|
|
87
|
+
properties: Record<string, unknown>;
|
|
88
|
+
signature: string;
|
|
89
|
+
threshold?: number;
|
|
90
|
+
diffPercentage?: number;
|
|
91
|
+
diffCount?: number;
|
|
92
|
+
error?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface TddResults {
|
|
96
|
+
total: number;
|
|
97
|
+
passed: number;
|
|
98
|
+
failed: number;
|
|
99
|
+
new: number;
|
|
100
|
+
errors: number;
|
|
101
|
+
comparisons: ComparisonResult[];
|
|
102
|
+
baseline: BaselineData | null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface BaselineData {
|
|
106
|
+
buildId: string;
|
|
107
|
+
buildName: string;
|
|
108
|
+
environment?: string;
|
|
109
|
+
branch?: string;
|
|
110
|
+
threshold: number;
|
|
111
|
+
createdAt?: string;
|
|
112
|
+
screenshots: BaselineScreenshot[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface BaselineScreenshot {
|
|
116
|
+
name: string;
|
|
117
|
+
originalName?: string;
|
|
118
|
+
sha256?: string;
|
|
119
|
+
id?: string;
|
|
120
|
+
properties: Record<string, unknown>;
|
|
121
|
+
path: string;
|
|
122
|
+
signature: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ============================================================================
|
|
126
|
+
// Upload Types
|
|
127
|
+
// ============================================================================
|
|
128
|
+
|
|
129
|
+
export interface UploadOptions {
|
|
130
|
+
screenshotsDir?: string;
|
|
131
|
+
buildName?: string;
|
|
132
|
+
branch?: string;
|
|
133
|
+
commit?: string;
|
|
134
|
+
message?: string;
|
|
135
|
+
environment?: string;
|
|
136
|
+
threshold?: number;
|
|
137
|
+
pullRequestNumber?: string;
|
|
138
|
+
parallelId?: string;
|
|
139
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface UploadProgress {
|
|
143
|
+
phase:
|
|
144
|
+
| 'scanning'
|
|
145
|
+
| 'processing'
|
|
146
|
+
| 'deduplication'
|
|
147
|
+
| 'uploading'
|
|
148
|
+
| 'completed';
|
|
149
|
+
message: string;
|
|
150
|
+
total?: number;
|
|
151
|
+
current?: number;
|
|
152
|
+
toUpload?: number;
|
|
153
|
+
existing?: number;
|
|
154
|
+
buildId?: string;
|
|
155
|
+
url?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface UploadResult {
|
|
159
|
+
success: boolean;
|
|
160
|
+
buildId: string;
|
|
161
|
+
url: string | null;
|
|
162
|
+
stats: {
|
|
163
|
+
total: number;
|
|
164
|
+
uploaded: number;
|
|
165
|
+
skipped: number;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface BuildResult {
|
|
170
|
+
status: 'completed' | 'failed' | 'pending';
|
|
171
|
+
build: unknown;
|
|
172
|
+
comparisons?: number;
|
|
173
|
+
passedComparisons?: number;
|
|
174
|
+
failedComparisons?: number;
|
|
175
|
+
url?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ============================================================================
|
|
179
|
+
// Error Types
|
|
180
|
+
// ============================================================================
|
|
181
|
+
|
|
182
|
+
export class VizzlyError extends Error {
|
|
183
|
+
code: string;
|
|
184
|
+
context: Record<string, unknown>;
|
|
185
|
+
timestamp: string;
|
|
186
|
+
constructor(
|
|
187
|
+
message: string,
|
|
188
|
+
code?: string,
|
|
189
|
+
context?: Record<string, unknown>
|
|
190
|
+
);
|
|
191
|
+
getUserMessage(): string;
|
|
192
|
+
toJSON(): {
|
|
193
|
+
name: string;
|
|
194
|
+
code: string;
|
|
195
|
+
message: string;
|
|
196
|
+
context: Record<string, unknown>;
|
|
197
|
+
timestamp: string;
|
|
198
|
+
stack?: string;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export class ConfigError extends VizzlyError {
|
|
203
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export class AuthError extends VizzlyError {
|
|
207
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export class NetworkError extends VizzlyError {
|
|
211
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export class UploadError extends VizzlyError {
|
|
215
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export class ScreenshotError extends VizzlyError {
|
|
219
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export class BuildError extends VizzlyError {
|
|
223
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export class TimeoutError extends VizzlyError {
|
|
227
|
+
duration: number;
|
|
228
|
+
constructor(
|
|
229
|
+
message: string,
|
|
230
|
+
duration?: number,
|
|
231
|
+
context?: Record<string, unknown>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export class ValidationError extends VizzlyError {
|
|
236
|
+
errors: string[];
|
|
237
|
+
constructor(
|
|
238
|
+
message: string,
|
|
239
|
+
errors?: string[],
|
|
240
|
+
context?: Record<string, unknown>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ============================================================================
|
|
245
|
+
// SDK Types
|
|
246
|
+
// ============================================================================
|
|
247
|
+
|
|
248
|
+
export interface VizzlySDKInstance extends EventEmitter {
|
|
249
|
+
config: VizzlyConfig;
|
|
250
|
+
|
|
251
|
+
/** Start the Vizzly server */
|
|
252
|
+
start(): Promise<{ port: number; url: string }>;
|
|
253
|
+
|
|
254
|
+
/** Stop the Vizzly server */
|
|
255
|
+
stop(): Promise<void>;
|
|
256
|
+
|
|
257
|
+
/** Get current configuration */
|
|
258
|
+
getConfig(): VizzlyConfig;
|
|
259
|
+
|
|
260
|
+
/** Capture a screenshot */
|
|
261
|
+
screenshot(
|
|
262
|
+
name: string,
|
|
263
|
+
imageBuffer: Buffer | string,
|
|
264
|
+
options?: ScreenshotOptions
|
|
265
|
+
): Promise<void>;
|
|
266
|
+
|
|
267
|
+
/** Upload all captured screenshots */
|
|
268
|
+
upload(options?: UploadOptions): Promise<UploadResult>;
|
|
269
|
+
|
|
270
|
+
/** Run local comparison in TDD mode */
|
|
271
|
+
compare(
|
|
272
|
+
name: string,
|
|
273
|
+
imageBuffer: Buffer | string
|
|
274
|
+
): Promise<ComparisonResult>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export class VizzlySDK extends EventEmitter implements VizzlySDKInstance {
|
|
278
|
+
config: VizzlyConfig;
|
|
279
|
+
|
|
280
|
+
constructor(config: VizzlyConfig, services: unknown);
|
|
281
|
+
|
|
282
|
+
start(): Promise<{ port: number; url: string }>;
|
|
283
|
+
stop(): Promise<void>;
|
|
284
|
+
getConfig(): VizzlyConfig;
|
|
285
|
+
screenshot(
|
|
286
|
+
name: string,
|
|
287
|
+
imageBuffer: Buffer | string,
|
|
288
|
+
options?: ScreenshotOptions
|
|
289
|
+
): Promise<void>;
|
|
290
|
+
upload(options?: UploadOptions): Promise<UploadResult>;
|
|
291
|
+
compare(
|
|
292
|
+
name: string,
|
|
293
|
+
imageBuffer: Buffer | string
|
|
294
|
+
): Promise<ComparisonResult>;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// ============================================================================
|
|
298
|
+
// Service Types
|
|
299
|
+
// ============================================================================
|
|
300
|
+
|
|
301
|
+
export interface Uploader {
|
|
302
|
+
upload(options: UploadOptions): Promise<UploadResult>;
|
|
303
|
+
waitForBuild(buildId: string, timeout?: number): Promise<BuildResult>;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface TddService {
|
|
307
|
+
downloadBaselines(
|
|
308
|
+
environment?: string,
|
|
309
|
+
branch?: string,
|
|
310
|
+
buildId?: string,
|
|
311
|
+
comparisonId?: string
|
|
312
|
+
): Promise<BaselineData | null>;
|
|
313
|
+
|
|
314
|
+
loadBaseline(): Promise<BaselineData | null>;
|
|
315
|
+
|
|
316
|
+
compareScreenshot(
|
|
317
|
+
name: string,
|
|
318
|
+
imageBuffer: Buffer,
|
|
319
|
+
properties?: Record<string, unknown>
|
|
320
|
+
): Promise<ComparisonResult>;
|
|
321
|
+
|
|
322
|
+
getResults(): TddResults;
|
|
323
|
+
printResults(): Promise<TddResults>;
|
|
324
|
+
updateBaselines(): number;
|
|
325
|
+
acceptBaseline(idOrComparison: string | ComparisonResult): Promise<{
|
|
326
|
+
name: string;
|
|
327
|
+
status: string;
|
|
328
|
+
message: string;
|
|
329
|
+
}>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface Services {
|
|
333
|
+
apiService: unknown;
|
|
334
|
+
authService: unknown;
|
|
335
|
+
configService: unknown;
|
|
336
|
+
projectService: unknown;
|
|
337
|
+
uploader: Uploader;
|
|
338
|
+
buildManager: unknown;
|
|
339
|
+
serverManager: unknown;
|
|
340
|
+
tddService: TddService;
|
|
341
|
+
testRunner: unknown;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ============================================================================
|
|
345
|
+
// Output Utilities
|
|
346
|
+
// ============================================================================
|
|
347
|
+
|
|
348
|
+
export interface OutputUtils {
|
|
349
|
+
info(message: string): void;
|
|
350
|
+
warn(message: string): void;
|
|
351
|
+
error(message: string): void;
|
|
352
|
+
success(message: string): void;
|
|
353
|
+
debug(category: string, ...args: unknown[]): void;
|
|
354
|
+
configure(options: { verbose?: boolean }): void;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// ============================================================================
|
|
358
|
+
// Main Exports
|
|
359
|
+
// ============================================================================
|
|
360
|
+
|
|
361
|
+
/** Create a new Vizzly SDK instance */
|
|
362
|
+
export function createVizzly(
|
|
363
|
+
config?: VizzlyConfig,
|
|
364
|
+
options?: { verbose?: boolean }
|
|
365
|
+
): Promise<VizzlySDKInstance>;
|
|
366
|
+
|
|
367
|
+
/** Take a screenshot for visual regression testing */
|
|
368
|
+
export function vizzlyScreenshot(
|
|
369
|
+
name: string,
|
|
370
|
+
imageBuffer: Buffer | string,
|
|
371
|
+
options?: {
|
|
372
|
+
properties?: Record<string, unknown>;
|
|
373
|
+
threshold?: number;
|
|
374
|
+
fullPage?: boolean;
|
|
375
|
+
}
|
|
376
|
+
): Promise<void>;
|
|
377
|
+
|
|
378
|
+
/** Configure the Vizzly client */
|
|
379
|
+
export function configure(config?: {
|
|
380
|
+
serverUrl?: string;
|
|
381
|
+
enabled?: boolean;
|
|
382
|
+
}): void;
|
|
383
|
+
|
|
384
|
+
/** Enable or disable screenshot capture */
|
|
385
|
+
export function setEnabled(enabled: boolean): void;
|
|
386
|
+
|
|
387
|
+
/** Create an uploader instance */
|
|
388
|
+
export function createUploader(
|
|
389
|
+
config?: {
|
|
390
|
+
apiKey?: string;
|
|
391
|
+
apiUrl?: string;
|
|
392
|
+
userAgent?: string;
|
|
393
|
+
command?: string;
|
|
394
|
+
upload?: UploadConfig;
|
|
395
|
+
},
|
|
396
|
+
options?: {
|
|
397
|
+
signal?: AbortSignal;
|
|
398
|
+
batchSize?: number;
|
|
399
|
+
timeout?: number;
|
|
400
|
+
}
|
|
401
|
+
): Uploader;
|
|
402
|
+
|
|
403
|
+
/** Create a TDD service instance */
|
|
404
|
+
export function createTDDService(
|
|
405
|
+
config: VizzlyConfig,
|
|
406
|
+
options?: {
|
|
407
|
+
workingDir?: string;
|
|
408
|
+
setBaseline?: boolean;
|
|
409
|
+
authService?: unknown;
|
|
410
|
+
}
|
|
411
|
+
): TddService;
|
|
412
|
+
|
|
413
|
+
/** Create all services with dependencies */
|
|
414
|
+
export function createServices(
|
|
415
|
+
config: VizzlyConfig,
|
|
416
|
+
command?: string
|
|
417
|
+
): Services;
|
|
418
|
+
|
|
419
|
+
/** Load configuration from file and environment */
|
|
420
|
+
export function loadConfig(options?: { cwd?: string }): Promise<VizzlyConfig>;
|
|
421
|
+
|
|
422
|
+
/** Define Vizzly configuration with type hints */
|
|
423
|
+
export function defineConfig(config: VizzlyConfig): VizzlyConfig;
|
|
424
|
+
|
|
425
|
+
/** Output utilities namespace */
|
|
426
|
+
export const output: OutputUtils;
|