Skip to content
Latest

Vitest SDK overview

Add vizzlyPlugin() to your config and keep using toMatchScreenshot(). Vizzly stores the screenshots and handles comparison and review.

Requirements

This integration is for Vitest browser mode.

Install

Terminal window
npm install -D @vizzly-testing/cli @vizzly-testing/vitest vitest @vitest/browser @vitest/browser-playwright

Configure Vitest

import { defineConfig } from 'vitest/config';
import { vizzlyPlugin } from '@vizzly-testing/vitest';
import { playwright } from '@vitest/browser-playwright';
export default defineConfig({
plugins: [vizzlyPlugin()],
test: {
browser: {
enabled: true,
instances: [
{
browser: 'chromium',
provider: playwright(),
},
],
},
},
});

The plugin disables Vitest’s own screenshot failure handling; Vizzly handles the comparison results.

Write tests

import { expect, test } from 'vitest';
import { page } from 'vitest/browser';
test('hero section', async () => {
await expect(page).toMatchScreenshot('hero.png', {
properties: { theme: 'dark' },
threshold: 5,
});
});

Run it

Local review:

Terminal window
npx vizzly tdd start
npx vitest

Cloud build:

Terminal window
npx vizzly run "npx vitest"

Use --wait on vizzly run if CI should fail on unresolved visual changes.

With or without --wait, vizzly run waits for pending uploads and reports failures before exiting. Upload failures preserve the test exit code. --wait waits for comparisons only when uploads succeed. Set VIZZLY_TOKEN in CI; vizzly run supplies the server and build routing values to Vitest.

Screenshot metadata

Vizzly adds framework: 'vitest', vitest: true, browser, and url metadata. Your properties override those defaults.

Image dimensions come from the captured bitmap. The client doesn’t generate viewport properties; any viewport-shaped values you supply remain user metadata.

Extra helpers

The package also exports:

  • getVizzlyStatus()
  • getVizzlyInfo()

Those are useful when you want to check whether the client is available inside tests.

Next steps