This guide will help you set up and start using the Visual Regression Testing tool locally. This is a TypeScript-based application that runs on Node.js.
- Node.js 20 or higher
- npm (comes with Node.js)
- Git
- OpenAI API key
-
Clone the Repository
git clone <repository-url> cd <repository-name>
-
Install Dependencies
npm install
-
Build TypeScript
npm run build
-
Install Playwright Browsers
npx playwright install --with-deps chromium
Note: Playwright browsers are required because Stagehand uses Playwright under the hood for browser automation. The Vercel MCP app uses
@sparticuz/chromiuminstead of bundling the full Playwright browser payload. -
Set Up Environment Variables Create a
.envfile in the root directory and add your OpenAI API key:OPENAI_API_KEY=your_api_key_hereOptional (for advanced features):
GITHUB_TOKEN– for posting PR commentsBRUNI_TOKENandBRUNI_API_URL– for Bruni API integrationGITHUB_REPOSITORY– repository identifier (e.g.,owner/repo)PR_NUMBER– pull request number (if not provided, will be inferred from GitHub event)
-
Run the Visual Regression Tests
You can run the tests using the built JavaScript:
GITHUB_TOKEN=<github-token> node dist/index.js --base-url <production-url> --pr-url <pull-request-url> --pages '<pages>'
Or run directly with TypeScript (for development):
GITHUB_TOKEN=<github-token> npm run dev -- --base-url <production-url> --pr-url <pull-request-url> --pages '<pages>'
The GitHub token is needed to write comments to the PR.
Note: The pages parameter should be a comma-separated list of paths (e.g.,
"/,/about,/contact").
The tool will:
- Capture screenshots of both the production and PR versions
- Compare the images and highlight differences
- Generate a report with the findings
- Provide AI-powered analysis of the changes
- Post a comment to the GitHub PR with the results
- Review the Configuration Guide to customize the testing behavior
- Check out Usage Examples for more advanced scenarios
- Learn about the Architecture to understand how the tool works