This guide explains how to configure the Visual Regression Testing tool to suit your specific needs.
The following environment variables can be set in your .env file:
OPENAI_API_KEY=your_api_key_hereThe main script accepts the following arguments:
node dist/index.js --base-url <production-url> --pr-url <pull-request-url>Or for development:
npm run dev -- --base-url <production-url> --pr-url <pull-request-url>--base-url: The URL of the production version to compare against--pr-url: The URL of the pull request version to test
--pages: Comma-separated list of page paths to test (e.g.,"/,/about,/contact"). If not provided, only the homepage (/) is tested.--bruni-token: Token for sending reports to Bruni API (optional)--bruni-api-url: URL for the Bruni API endpoint (optional, defaults tohttps://app.brunivisual.com/api/tests)
The GitHub Action can be configured in your workflow file:
name: Visual Regression Test
on:
pull_request:
branches: [main]
jobs:
visual-regression:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Visual Regression Test
uses: ./
with:
base-url: ${{ github.event.pull_request.base.ref }}
pr-url: ${{ github.event.pull_request.head.ref }}
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}To test multiple pages, add the pages parameter as a JSON array:
name: Visual Regression Test
on:
pull_request:
branches: [main]
jobs:
visual-regression:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Visual Regression Test
uses: ./
with:
base-url: "https://www.example.com/"
pr-url: "https://example-git-${{ github.head_ref }}-myusername.vercel.app"
pages: '["/", "/about", "/contact", "/pricing"]'
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}Note: The pages parameter accepts a JSON array string. When running locally, use comma-separated format: "/,/about,/contact".
-
URL Selection
- Use stable production URLs
- Ensure PR URLs are accessible
- Test with different page types
-
Multi-Page Testing
- Start with critical pages (homepage, key landing pages)
- Test pages with dynamic content separately
- Consider page load times when selecting pages to test
-
Output Management
- Regularly clean up old output files
- Store important baselines
- Archive significant changes
If you encounter issues:
- Check your environment variables
- Ensure URLs are accessible
- Verify GitHub token permissions
- For multi-page testing, ensure all page paths are valid
For more help, see the Troubleshooting Guide.