Skip to content
Latest

JavaScript SDK overview

Use the JavaScript client included in the CLI package.

Install it

Terminal window
npm install -D @vizzly-testing/cli

Use it in tests

import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
let screenshot = await page.screenshot();
await vizzlyScreenshot('homepage', screenshot);

Await the capture so your test doesn’t finish before the screenshot is sent.

Run modes

Local TDD mode

Terminal window
npx vizzly tdd start --open

Run your tests normally in another terminal. The client auto-discovers the local server through VIZZLY_SERVER_URL or .vizzly/server.json.

Cloud mode

Terminal window
npx vizzly run "npm test" --wait

Your capture code stays the same; run uploads the screenshots for review.

Useful metadata

await vizzlyScreenshot('dashboard', screenshot, {
properties: {
browser: 'chrome',
viewport: { width: 1920, height: 1080 },
theme: 'dark',
},
});

Use properties for details such as theme or locale. To keep separate baselines for those values, add their keys to local signatureProperties or the cloud project’s matching settings.

Keep SDK options like threshold, minClusterSize, fullPage, requestTimeout, and buildId at the top level. Every key inside properties is kept as user metadata. A property named threshold or component doesn’t change how Vizzly captures or compares the image. See the client reference for supported options.

Next steps