Skip to main content

Playwright plugin

Already have a Playwright suite? Drop visual assertions straight into your existing tests with @frontguard/playwright — no separate run, baselines managed for you.

Setup

tests/visual.spec.ts
import { visualTest } from '@frontguard/playwright';

test('checkout page', async ({ page }) => {
  await page.goto('/checkout');

  // capture + diff against baseline, with AI analysis
  const result = await visualTest(page, 'checkout', {
    ai: { provider: 'openai', model: 'gpt-4o' },
  });

  expect(result.passed).toBe(true);
});

visualTest API

Or enable AI with defaults — ai: true uses OpenAI. Update baselines by setting FRONTGUARD_UPDATE=1.

Updating baselines

The plugin reuses your test's already-rendered page — no second browser launch — so it adds visual coverage with almost no extra runtime.