Quick Start
Run your first visual regression test with Frontguard in under 5 minutes.
Quick Start
Get visual regression testing running in under 5 minutes.
Initialize Configuration
Run frontguard init in your project root. It auto-detects your framework (Next.js, Remix, SvelteKit, Nuxt, Astro) and generates a config file:
npx frontguard initThis creates frontguard.config.ts:
export default {
version: 1,
baseUrl: 'http://localhost:3000',
discover: {
startUrl: '/',
maxDepth: 3,
exclude: ['/admin/*', '/api/*'],
},
viewports: [375, 768, 1440],
browsers: ['chromium'],
threshold: 0.1,
ignore: [
{ selector: '.dynamic-timestamp' },
],
};Start Your Dev Server
Frontguard needs a running application to screenshot:
npm run devMake sure your app is accessible at the baseUrl defined in your config.
Capture Baselines
Your first run captures baseline screenshots โ the "known good" state of your application:
npx frontguard run --url http://localhost:3000Since there are no existing baselines, all pages are marked as NEW and saved automatically.
frontguard v0.1.0
๐ Discovering routes... found 12 routes
๐ฅ Rendering 12 routes ร 3 viewports
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
RESULTS 12 routes
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
/ 375 768 1440 NEW
โ
/about 375 768 1440 NEW
โ
/pricing 375 768 1440 NEW
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
0 regressions ยท 0 warnings ยท 0 passed ยท 12 newMake Changes and Re-run
Now make a CSS or layout change in your code, then run Frontguard again:
npx frontguard run --url http://localhost:3000Frontguard compares the new screenshots against your baselines and reports differences:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
RESULTS 12 routes
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ / 375 768 1440 PASS
โ /about 375 768 1440 PASS
โ /pricing 375 768 1440 REGRESSION
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ /pricing @ 375px
AI: "Button width changed from 100% to auto,
causing text truncation on mobile."
Severity: ๐ด Critical (confidence: 94%)
1 regression ยท 0 warnings ยท 11 passed ยท 0 newUpdate Baselines
When changes are intentional, accept the new screenshots as baselines:
npx frontguard update-baselinesThis replaces old baselines with the current screenshots. Future runs compare against this new state.
What Happens Under the Hood
- Route Discovery โ Frontguard crawls your app starting from the start URL, discovering all navigable pages
- Smart Filtering โ If a dependency graph is available, only pages affected by your changes are rendered
- Multi-Viewport Rendering โ Each route is captured at every configured viewport width using Playwright
- Pixel Diff โ Screenshots are compared against baselines using
pixelmatchwith SSIM fallback - AI Analysis โ If configured, visual diffs are sent to GPT-4V or Claude for classification and explanation
- Reporting โ Results are output to console, JSON, HTML report, and optionally as a GitHub PR comment
The pipeline uses error boundaries at every stage. If one page fails to render, the rest still complete.
Add to Your Scripts
Add Frontguard to your package.json scripts for easy access:
{
"scripts": {
"test:visual": "frontguard run --url http://localhost:3000",
"test:visual:update": "frontguard update-baselines"
}
}Next Steps
- CLI Commands โ All available commands and options
- Configuration โ Full config file reference
- CI/CD Integration โ Run in GitHub Actions
- AI Analysis โ Enable AI-powered regression explanations