UNPKG

@vizzly-testing/cli

Version:

Visual review platform for UI developers and designers

109 lines (108 loc) 3.6 kB
/** * Create a new Vizzly instance with custom configuration * * @param {import('../types').VizzlyConfig} [config] - Configuration options * @returns {Promise<VizzlySDK>} Configured Vizzly SDK instance * * @example * // Create with custom config * import { createVizzly } from '@vizzly-testing/cli/sdk'; * * const vizzly = await createVizzly({ * apiKey: process.env.VIZZLY_TOKEN, * apiUrl: 'https://vizzly.dev', * server: { * port: 3003, * enabled: true * } * }); * * // Start the server * await vizzly.start(); * * // Take screenshots * const screenshot = await getScreenshotSomehow(); * await vizzly.screenshot('my-test', screenshot); * * // Upload results * const result = await vizzly.upload(); * console.log(`Build URL: ${result.url}`); * * // Cleanup * await vizzly.stop(); */ export function createVizzly(config?: any, options?: {}): Promise<VizzlySDK>; /** * @typedef {Object} VizzlySDK * @property {Function} start - Start the Vizzly server * @property {Function} stop - Stop the Vizzly server * @property {Function} screenshot - Capture a screenshot * @property {Function} upload - Upload screenshots to Vizzly * @property {Function} compare - Run local comparison (TDD mode) * @property {Function} getConfig - Get current configuration * @property {Function} on - Subscribe to events * @property {Function} off - Unsubscribe from events */ /** * VizzlySDK class implementation * @class * @extends {EventEmitter} */ export class VizzlySDK extends EventEmitter<[never]> { /** * @param {import('../types').VizzlyConfig} config - Configuration * @param {import('../utils/logger').Logger} logger - Logger instance * @param {Object} services - Service instances */ constructor(config: any, logger: import("../utils/logger").Logger, services: any); config: any; logger: import("../utils/logger.js").Logger; services: any; server: ScreenshotServer; currentBuildId: any; /** * Stop the Vizzly server * @returns {Promise<void>} */ stop(): Promise<void>; /** * Get current configuration * @returns {Object} Current config */ getConfig(): any; /** * Start the Vizzly server * @returns {Promise<{port: number, url: string}>} Server information */ start(): Promise<{ port: number; url: string; }>; /** * Capture a screenshot * @param {string} name - Screenshot name * @param {Buffer} imageBuffer - Image data * @param {import('../types').ScreenshotOptions} [options] - Options * @returns {Promise<void>} */ screenshot(name: string, imageBuffer: Buffer, options?: any): Promise<void>; /** * Upload all captured screenshots * @param {import('../types').UploadOptions} [options] - Upload options * @returns {Promise<import('../types').UploadResult>} Upload result */ upload(options?: any): Promise<any>; /** * Run local comparison in TDD mode * @param {string} name - Screenshot name * @param {Buffer} imageBuffer - Current image * @returns {Promise<import('../types').ComparisonResult>} Comparison result */ compare(name: string, imageBuffer: Buffer): Promise<any>; } export { loadConfig } from "../utils/config-loader.js"; export { createLogger } from "../utils/logger.js"; export { createUploader } from "../services/uploader.js"; export { createTDDService } from "../services/tdd-service.js"; import { EventEmitter } from 'events'; import { ScreenshotServer } from '../services/screenshot-server.js';