-
Install dependencies in the action directory:
cd /path/to/auto-pr-screenshots pnpm install -
Build the action:
pnpm build
This is the fastest way to test during development:
# Install tsx globally (if not already installed)
pnpm add -g tsx
# Run the test script
pnpm test:local /path/to/your/project- Sets up fake GitHub Actions environment
- Changes to your project directory
- Runs the action
- Skips PR comment posting (local testing)
- Shows debug output
Edit test-local.ts to:
- Change URL:
process.env.INPUT_URL = 'http://localhost:8080' - Change browsers:
process.env.INPUT_BROWSERS = 'chromium,firefox' - Use a config file:
process.env.INPUT_CONFIG_FILE = 'my-config.yml' - Test upload (needs real GitHub token):
process.env.INPUT_SKIP_COMMENT = 'false'
The simplest way to test - just provide a URL:
# Start your app first
cd your-project
npm run dev &
# Wait for it to be ready
npx wait-on http://localhost:3000
# Run the action
cd /path/to/auto-pr-screenshots
pnpm test:local /path/to/your/project-
Create a test config in your project:
cd /path/to/your/project mkdir -p .githubCreate
.github/screenshots.config.yml:version: 1 screenshots: - name: home-large url: http://localhost:3000 viewport: width: 1920 height: 1080 wait_for: '[data-testid="hero-section"]' - name: mobile-home url: http://localhost:3000 viewport: width: 390 height: 844 deviceScaleFactor: 3 - name: form-interaction url: http://localhost:3000/contact viewport: width: 1440 height: 900 steps: - click: 'button[data-testid="open-form"]' - wait: 500 - fill: selector: 'input[name="email"]' text: 'test@example.com' - wait_for: '[data-testid="form-ready"]'
-
Run the test:
pnpm test:local /path/to/your/project
To test the fallback framework detection:
# Go to a Next.js, Vite, or other supported framework project
cd /path/to/nextjs-project
# Run without URL or config - should detect framework
cd /path/to/auto-pr-screenshots
pnpm test:local /path/to/nextjs-projectNote: Framework detection assumes your app runs on default ports (e.g., 3000 for Next.js).
-
Enable debug logging:
export RUNNER_DEBUG=1 export DEBUG=screenshots:*
-
Test different browsers:
export INPUT_BROWSERS='chromium,firefox,webkit' pnpm test:local /path/to/your/project
-
Test error handling:
# Test with wrong URL export INPUT_URL='http://localhost:9999' export INPUT_FAIL_ON_ERROR='false' pnpm test:local /path/to/your/project
- Make sure your app is running before starting the action
- Use
wait-onto ensure the app is ready:npx wait-on http://localhost:3000 --timeout 60000
- Add a
wait_forselector to ensure the page is loaded - Increase wait times in your config
- Check if your app requires authentication
- Specify exact viewport dimensions in config
- Use
deviceScaleFactorfor high-DPI screenshots
- Verify selectors are correct
- Add wait times between steps
- Use
wait_forafter interactions
- URL-based capture works
- Config file is loaded correctly
- Multiple viewports work
- Multiple browsers work
- Interactions (click, fill, wait) work
- wait_for selectors work
- Full page screenshots work
- Error handling with fail-on-error: false
- Framework auto-detection (when no URL/config)
- Custom branch names
- Skip comment functionality