Automate visual regression testing for your web applications. Compare feature branch changes against main branch baselines automatically.
images/visual-regression-testing-vscode-extension.mp4
- π― Automatic baseline comparison - Captures main branch screenshots and compares with your feature branch
- π Smart branch switching - Handles all Git operations automatically
- π Zero configuration - Works with your existing Playwright setup
- π HTML reports - Side-by-side comparison of changes
- π Environment variables - Pass custom variables for auth bypass and more
- β‘ Multiple URL testing - Test several routes in one run
- π Status bar integration - Quick access to tests and reports from the status bar (optional)
- Install from VS Code Marketplace or download the
.vsixfile - Ensure Playwright is installed:
npm install -D @playwright/test && npx playwright install
π New to this extension? Check out the Complete Getting Started Guide for a step-by-step tutorial.
Create tests/visual/pages.spec.ts:
import { test, expect } from '@playwright/test';
// Get URLs from environment (comma-separated for multiple URLs)
const testUrls = process.env.TEST_URLS
? process.env.TEST_URLS.split(',')
: [process.env.TEST_URL || 'http://localhost:3000/'\]\;
// Generate a test for each URL
for (const testUrl of testUrls) {
test(\`visual test for \${testUrl}\`, async ({ page }) => {
await page.goto(testUrl);
await page.waitForLoadState('networkidle');
// Generate unique filename from URL path
const urlPath = new URL(testUrl).pathname;
const filename = urlPath
.replace(/^\//, '')
.replaceAll('/', '-')
.replaceAll(/[^a-zA-Z0-9-_]/g, '_')
|| 'homepage';
await expect(page).toHaveScreenshot(\`\${filename}.png\`, { fullPage: true });
});
}Add to .vscode/settings.json:
{
"visualRegression.testPath": "tests/visual",
"visualRegression.serverStartCommand": "npm run dev",
"visualRegression.serverPort": 3000,
"visualRegression.mainBranch": "main",
"visualRegression.testImportPath": "../path-to-custom-fixtures",
"visualRegression.waitForSelector": "selector-rule-to-show-page-has-loaded",
"visualRegression.environmentVariables": {
"NEXT_PUBLIC_PLAYWRIGHT": "true"
}
}- Open Command Palette (`Cmd+Shift+P`)
- Type "Visual Regression: Run Test"
- Enter URL paths (comma-separated for multiple): `/,/unauthorised,/access-denied`
Or use the status bar:
- Click the "Visual Tests" item in the status bar (bottom left)
- Select "Run Test" or "Show Report" from the menu
- Clears existing snapshots
- Switches to main branch and captures baseline screenshots
- Returns to your feature branch
- Compares new screenshots against baseline
- Shows HTML report if differences are found
| Setting | Default | Description |
|---|---|---|
| `testPath` | `tests/visual` | Path to Playwright test files |
| `mainBranch` | `main` | Main branch name |
| `serverStartCommand` | `npm run dev` | Command to start dev server |
| `serverPort` | `3000` | Dev server port |
| `serverStartupTime` | `5000` | Server startup wait time (ms) |
| `environmentVariables` | `{}` | Custom environment variables |
| `testImportPath` | `@playwright/test` | Import path for test fixtures |
| `waitForSelector` | `""` | Optional CSS selector to wait for before taking screenshots |
| `showStatusBar` | `true` | Show/hide status bar item |
| `notifyOnCompletion` | `true` | Show notification when tests complete |
| `autoRunOnSave` | `false` | Automatically run tests when files are saved |
| `autoRunDelay` | `2000` | Delay before auto-running tests (ms) |
Pass variables to bypass auth or enable mocking:
{
"visualRegression.environmentVariables": {
"NEXT_PUBLIC_PLAYWRIGHT": "true",
"API_MOCKING": "enabled"
}
}In your middleware:
export function middleware(request: NextRequest) {
if (process.env.NEXT_PUBLIC_PLAYWRIGHT === 'true') {
return NextResponse.next();
}
// Normal auth flow...
}Create `tests/visual/pages.spec.ts` with the template above.
npm install -D @playwright/test && npx playwright installgit initAdd environment variables to bypass auth (see Auth Bypass Example above).
Increase `serverStartupTime` in settings (e.g., `10000` for 10 seconds).
Stop your dev server before running tests, or change `serverPort` in settings.
Expected if your changes don't affect visual appearance.
VS Code notifications appear in the bottom right corner. If you missed them:
- Click the bell icon (π) in the bottom right status bar
- Or check View β Notifications to see recent notifications
- Alternatively, check the Output panel for detailed logs
- Open Settings (`Cmd+,`)
- Search "Playwright"
- Uncheck "Playwright: Show Test Explorer"
The extension adds a "Visual Tests" item to the status bar for quick access. To hide it:
- Open Settings (`Cmd+,`)
- Search "Visual Regression: Show Status Bar"
- Uncheck to hide, or check to show
- Changes apply immediately - no reload required
- Open Output panel: `View β Output`
- Select "Visual Regression Testing"
- Run Test - Test one or more URLs
- Show Playwright Report - View latest test report
- Node.js 16+
- Git repository
- Playwright (`@playwright/test`)
- Dev server command
MIT
Love this extension? Star us and buy me a coffee
Want to make this extension even more awesome? Send us your wish.
Hate how it is working? Raise an issue.


