Source:
ocean/docs/E2E_TESTING.md| ✏️ Edit on GitHub
E2E Testing with Stagehand
This document explains how to run end-to-end tests on deployed Vercel URLs using Stagehand, an AI-powered browser automation tool.
Overview
We use Stagehand for E2E testing because it provides:
- AI-powered element selection and interaction
- Better handling of dynamic content
- Comprehensive error reporting
- Screenshot capabilities
- Network and console error tracking
Running Tests
Quick Start
Test all deployed URLs:
pnpm test:e2e
Run tests in headless mode:
pnpm test:e2e:headless
What the Tests Do
- Environment Check: Verifies that Supabase environment variables are loaded
- Form Filling: Uses AI to fill out the signup form with test data
- Form Submission: Submits the form and waits for navigation
- Error Detection: Captures console errors, network failures, and form validation errors
- Screenshots: Takes screenshots before submission and on errors
Test Results
Test results are saved to:
tests/e2e/reports/signup-test-{timestamp}.json- Detailed test resultstests/e2e/screenshots/- Visual captures of form states
Troubleshooting Signup Form Issues
1. Check Environment Variables
Visit /api/health on your deployed URL to see:
- Which environment variables are present
- Whether Supabase connection is working
- Debugging information
Example: https://ocean-goldfish.vercel.app/api/health
2. Common Issues
Form Not Submitting:
- Environment variables not set in Vercel dashboard
- Supabase rate limiting (check error messages)
- Network connectivity issues
Missing Environment Variables:
- Go to Vercel Dashboard → Your Project → Settings → Environment Variables
- Add:
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEY
- Redeploy the project
Validation Errors:
- Check console for specific field validation failures
- Review screenshots in
tests/e2e/screenshots/
3. Manual Testing Steps
If automated tests fail, manually verify:
- Open the deployed URL
- Open browser DevTools (F12)
- Check Console for errors
- Check Network tab for failed requests
- Try submitting the form and observe the response
Advanced Usage
Testing Specific URLs
Modify TEST_URLS in tests/e2e/test-signup.mjs:
const TEST_URLS = ['https://your-deployment.vercel.app']
Using BrowserBase (Cloud Testing)
For running tests in the cloud, set up BrowserBase:
- Get API key from https://browserbase.com
- Set
BROWSERBASE_API_KEYenvironment variable - Update Stagehand config:
const stagehand = new Stagehand({
env: 'BROWSERBASE',
apiKey: process.env.BROWSERBASE_API_KEY,
})
CI/CD Integration
Add to your GitHub Actions workflow:
- name: Run E2E Tests
run: pnpm test:e2e:headless
env:
BROWSERBASE_API_KEY: ${{ secrets.BROWSERBASE_API_KEY }}
Next Steps
- Add more test scenarios (error cases, edge cases)
- Integrate with CI/CD pipeline
- Set up scheduled test runs
- Add performance monitoring
- Create visual regression tests