🤖 Automatically generate and run end-to-end tests for your Pull Requests using Claude API and Magnitude testing framework.
- 🔍 Smart Analysis: Analyzes PR changes and repository context
- 🧪 Auto-Generated Tests: Creates comprehensive E2E tests using Claude AI
- ⚡ Instant Execution: Runs tests immediately using Magnitude framework
- 💬 PR Integration: Comments results directly on your Pull Request
- 🎯 Zero Configuration: Works out of the box with sensible defaults
Create .github/workflows/pr-tests.yml:
In your repository settings, add:
- CLAUDE_API_KEY: Your Claude API key from Anthropic Console
Optional secrets for authentication:
- TEST_USER_EMAIL: Email for test user authentication (if preview URLs require login)
- TEST_USER_PASSWORD: Password for test user authentication (if preview URLs require login)
The action will automatically:
- Analyze your PR changes
- Generate relevant tests
- Execute the tests
- Comment the results on your PR
The action will add a comment to your PR like this:
| claude-api-key | Claude API key from Anthropic | ✅ | - |
| github-token | GitHub token for API access | ❌ | ${{ github.token }} |
| test-examples | Custom test examples to guide Claude | ❌ | Built-in examples |
| output-dir | Directory for generated test files | ❌ | .github/generated-tests |
| timeout | Test execution timeout (seconds) | ❌ | 120 |
| comment-on-pr | Whether to comment results on PR | ❌ | true |
| wait-for-preview | Wait for preview URLs to appear in PR comments (seconds) | ❌ | 60 |
| base-url | Base URL to use for tests (overrides preview URL detection) | ❌ | - |
| test-user-email | Email for test user authentication (if preview requires login) | ❌ | - |
| test-user-password | Password for test user authentication (if preview requires login) | ❌ | - |
| test-results | JSON string with test execution results |
| test-file-path | Path to generated test file |
| tests-passed | Boolean indicating if tests passed |
- Go to Anthropic Console
- Create an API key
- Add it to your repository secrets as CLAUDE_API_KEY
The action needs access to:
- Read repository content and PR details
- Write comments on Pull Requests
- Execute tests in the GitHub Actions environment
This is handled automatically by the default GITHUB_TOKEN.
The action can automatically detect preview URLs from PR comments (Vercel, Netlify, Railway, etc.) and use them for testing. If your preview environments require authentication, you can configure test credentials:
- Automatic Detection: The action scans PR comments for preview URLs
- Manual Override: Use base-url input to specify a custom URL
- Authentication: Set test-user-email and test-user-password for login-protected previews
- Environment Variables: Tests can access credentials via process.env.TEST_USER_EMAIL and process.env.TEST_USER_PASSWORD
- Vercel (*.vercel.app)
- Netlify (*.netlify.app)
- Railway (*.railway.app)
- Custom preview URLs matching pattern https://preview-*
- Context Analysis: Fetches PR details, changed files, and repository structure
- Test Generation: Sends context to Claude API with your test examples
- Test Execution: Runs generated tests using Magnitude in a headless browser
- Results Reporting: Comments detailed results on the PR
Tests fail to execute
- Ensure your app can run in the GitHub Actions environment
- Check that all dependencies are properly installed
- Verify test syntax is compatible with Magnitude
Claude API errors
- Verify your API key is correctly set in secrets
- Check API rate limits and quotas
- Ensure your repository context isn't too large
No tests generated
- Check that your PR has meaningful code changes
- Ensure changed files are in supported formats
- Review the action logs for detailed error messages
Enable debug logging by setting the ACTIONS_STEP_DEBUG secret to true in your repository.
- Works best with web applications that can run in CI environments
- Requires Magnitude-compatible test structure
- Subject to Claude API rate limits and token limits
- Generated tests may require manual review and adjustment
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests: npm test
- Build: npm run build
- Submit a Pull Request
MIT License - see LICENSE file for details.
.png)


