mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-25 14:14:57 +00:00
2.3 KiB
2.3 KiB
E2E Test Configuration Fix
Problem
Playwright E2E tests were timing out with the error:
Error: Timed out waiting 180000ms from config.webServer.
Root Cause
Port mismatch between Playwright configuration and Vite dev server:
playwright.config.tswas configured to expect server on port 5173 (Vite's default)vite.config.tswas configured to run server on port 5000
This caused Playwright to wait for a server that would never respond on the expected port.
Changes Made
1. Fixed Port Configuration in playwright.config.ts
- Changed
baseURLfromhttp://localhost:5173→http://localhost:5000 - Changed
webServer.urlfromhttp://localhost:5173→http://localhost:5000 - Reduced
webServer.timeoutfrom180000ms→120000ms(2 minutes) - Reduced
timeoutfrom60000ms→45000msper test - Reduced
expect.timeoutfrom15000ms→10000ms - Reduced
actionTimeoutfrom15000ms→10000ms - Reduced
navigationTimeoutfrom30000ms→20000ms
2. Optimized Test Files
e2e/smoke.spec.ts
- Replaced
page.waitForTimeout()withpage.waitForLoadState('networkidle')for more reliable waits - Added explicit timeout values to all
page.goto()calls - Reduced individual test timeouts (20-30s instead of 30-45s)
- More efficient waiting strategies
e2e/codeforge.spec.ts
- Same optimizations as smoke tests
- Better handling of async operations
- Explicit timeouts prevent hanging
Benefits
- ✅ Tests now connect to correct port
- ✅ Faster test execution (no arbitrary waits)
- ✅ More reliable (networkidle vs fixed timeouts)
- ✅ Better timeout management per test
- ✅ Clearer failure messages when tests do fail
Test Execution
Run E2E tests with:
npm run test:e2e
Or with the fallback:
npm run test:e2e --if-present || echo "No E2E tests configured"
CI/CD Integration
The tests will now:
- Start the dev server on port 5000
- Wait up to 2 minutes for server to be ready
- Run tests with appropriate per-test timeouts
- Retry failed tests 2x in CI environments
- Generate HTML reports
Future Improvements
Consider adding:
- More granular test timeouts based on test complexity
- Test parallelization configuration
- Screenshot comparison tests
- Visual regression testing
- API mocking for faster, more isolated tests