@vizzly-testing/cli
Version:
Visual review platform for UI developers and designers
77 lines (76 loc) • 2.32 kB
TypeScript
/**
* Take a screenshot for visual regression testing
*
* @param {string} name - Unique name for the screenshot
* @param {Buffer} imageBuffer - PNG image data as a Buffer
* @param {Object} [options] - Optional configuration
* @param {Record<string, any>} [options.properties] - Additional properties to attach to the screenshot
* @param {number} [options.threshold=0] - Pixel difference threshold (0-100)
* @param {string} [options.variant] - Variant name for organizing screenshots
* @param {boolean} [options.fullPage=false] - Whether this is a full page screenshot
*
* @returns {Promise<void>}
*
* @example
* // Basic usage
* import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
*
* const screenshot = await page.screenshot();
* await vizzlyScreenshot('homepage', screenshot);
*
* @example
* // With properties and threshold
* await vizzlyScreenshot('checkout-form', screenshot, {
* properties: {
* browser: 'chrome',
* viewport: '1920x1080'
* },
* threshold: 5
* });
*
* @throws {VizzlyError} When screenshot capture fails or client is not initialized
*/
export function vizzlyScreenshot(name: string, imageBuffer: Buffer, options?: {
properties?: Record<string, any>;
threshold?: number;
variant?: string;
fullPage?: boolean;
}): Promise<void>;
/**
* Wait for all queued screenshots to be processed
*
* @returns {Promise<void>}
*
* @example
* afterAll(async () => {
* await vizzlyFlush();
* });
*/
export function vizzlyFlush(): Promise<void>;
/**
* Check if the Vizzly client is initialized and ready
*
* @returns {boolean} True if client is ready, false otherwise
*/
export function isVizzlyReady(): boolean;
/**
* Configure the client with custom settings
*
* @param {Object} config - Configuration options
* @param {string} [config.serverUrl] - Server URL override
* @param {boolean} [config.enabled] - Enable/disable screenshots
*/
export function configure(config?: {
serverUrl?: string;
enabled?: boolean;
}): void;
/**
* Enable or disable screenshot capture
* @param {boolean} enabled - Whether to enable screenshots
*/
export function setEnabled(enabled: boolean): void;
/**
* Get information about Vizzly client state
* @returns {Object} Client information
*/
export function getVizzlyInfo(): any;