Overview
Visual regression tests capture screenshots of your resources and compare them against saved baselines. This catches unintended visual changes across themes, display modes, and hosts. Screenshot comparisons only run when you pass--visual. Without it, mcp.screenshot() calls are silently skipped, so you can include them in your regular e2e tests without affecting normal runs.
Running Visual Tests
Writing Visual Tests
Usemcp.screenshot() in any e2e test. It accepts an optional name and Playwright toHaveScreenshot options:
Screenshot Targets
By default,screenshot() captures the app content inside the double-iframe. Use the target option to capture the full inspector page, or pass a specific element locator:
Configuring Visual Defaults
Pass avisual option to defineConfig() to set project-wide defaults for screenshot comparison:
toHaveScreenshot options (threshold, maxDiffPixelRatio, maxDiffPixels, animations, etc.) are supported. The snapshotPathTemplate controls where baseline images are stored.
See Also
E2E Testing
Full E2E testing guide with the mcp fixture.
Inspector
The runtime that powers visual tests.