E2E Testing Troubleshooting Guide
This guide covers common issues encountered when running Playwright E2E tests and their solutions.
Test Execution Issues
Tests Fail with "Target closed"
Cause: Page or context closed prematurely
Solution: Ensure all async operations are awaited.
// Good
await page.click('button')
await page.waitForLoadState('networkidle')
// Bad - missing await
page.click('button')"Element not found" Errors
Debugging strategies:
// Add screenshot to see page state
await page.screenshot({ path: 'debug.png' })
// Use playwright inspector
await page.pause()
// Check if element exists
const element = await page.getByRole('button', { name: 'Reply' })
console.log('Element count:', await element.count())
// Wait for element explicitly
await page.waitForSelector('button:has-text("Reply")', { timeout: 10000 })Common causes:
- Element not yet rendered (add explicit wait)
- Wrong selector (verify in browser DevTools)
- Element in different frame/context
- Element hidden by CSS
Tests Pass Locally but Fail in CI
Common causes:
Timing issues: CI may be slower - use explicit waits, not arbitrary timeouts
// Good await expect(page.getByText('Success')).toBeVisible() // Avoid await page.waitForTimeout(3000)Environment differences: Check
LAUNCH_URLin CI configurationParallel execution: Run with
--workers=1to debug race conditionspnpm e2e --workers=1Screen resolution: CI may use different viewport size
// Set explicit viewport in test await page.setViewportSize({ width: 1280, height: 720 })
Provisioning Issues
Provisioning Fails
Check:
- Admin credentials (
E2E_ADMIN_PW) are correct - Provisioning API is accessible at configured URL
- Mail domain (
MX_DOMAIN) is properly configured - Database is accessible and migrations are applied
Debug with verbose logging:
DEBUG=pw:api pnpm e2eCommon errors:
401 Unauthorized: CheckE2E_ADMIN_USERandE2E_ADMIN_PWConnection refused: Verify backend is runningContext creation failed: Check database connectivity
"Storage state not found"
Cause: Provisioning fixture didn't run or failed
Check:
ls -la e2e/output/.auth/
# Should contain user-*.json files with authentication tokensSolution:
- Delete existing auth files:
rm -rf e2e/output/.auth/ - Re-run tests to trigger fresh provisioning
Real-time Collaboration Issues
WebSocket Tests Flaky
Symptoms:
- Multi-user tests fail intermittently
- Changes not synchronized between users
- Timeout waiting for real-time updates
Solutions:
// Increase timeout for WebSocket synchronization
await expect(user2Page.getByText('expected text')).toBeVisible({ timeout: 10000 })
// Wait for specific network activity
await page.waitForResponse(resp => resp.url().includes('/ws') && resp.status() === 101)
// Verify WebSocket connection established
await page.waitForFunction(() => window.wsConnected === true)Check:
- Backend WebSocket server is running
- No firewall blocking WebSocket connections
- Browser console for WebSocket errors
Yjs Synchronization Issues
Symptoms:
- Collaborative edits not appearing
- State conflicts between users
- Document version mismatches
Debug:
// Enable Yjs debug logs in test
await page.evaluate(() => {
localStorage.setItem('yjs-debug', 'true')
})
// Check Yjs document state
const docState = await page.evaluate(() => {
return window.yDoc?.getText().toString()
})
console.log('Yjs document state:', docState)Browser-Specific Issues
WebKit Issues
getByRole('paragraph').fill() not working in contenteditable:
// Skip in WebKit
test('edit draft', async ({ page, browserName }) => {
if (browserName === 'webkit') {
test.fixme(true, 'WebKit contenteditable fill issue')
}
// Test code
})
// Alternative for WebKit
await page.locator('.tiptap').click()
await page.keyboard.type('text content')page.reload() hangs:
- Known WebKit bug #300402
- Use
page.goto(page.url())as workaround or skip test
Firefox Issues
page.reload() never resolves in deep linking tests:
// Skip in Firefox
if (browserName === 'firefox') {
test.fixme(true, 'Firefox reload hangs')
}Environment Setup Issues
Backend Not Responding
Check:
# Verify backend is running
curl http://127.0.0.1:8080/health
# Check logs
pnpm dev
# Look for errors in outputCommon issues:
- Database not running (start PostgreSQL)
- Port 8080 already in use
- Environment variables not loaded
UI Dev Server Issues
Check:
# Verify UI is accessible
curl -k https://localhost:5173/
# Check Vite dev server logs
pnpm vite devCommon issues:
- SSL certificates missing (run
mkcertsetup) - Port 5173 already in use
- Backend proxy configuration incorrect
Database Connection Issues
Symptoms:
- Tests fail with database errors
- Provisioning fails with connection errors
Debug:
# Check database is running
psql -U postgres -c "SELECT version()"
# Verify database exists
psql -U postgres -l | grep teams
# Test connection with app credentials
psql -U teams_user -d teams_dev -c "SELECT 1"Solutions:
- Start PostgreSQL:
brew services start postgresql(macOS) orsystemctl start postgresql(Linux) - Recreate database:
DATABASE_ADMIN_USER=postgres pnpm create:database - Check credentials in
.env
Test Data Issues
Email Not Appearing
Check:
- Email sent successfully (check
sendMailfixture output) - Correct folder selected in UI
- Thread list refreshed/loaded
- No mail filtering hiding the email
Debug:
// Log all threads in folder
const threads = await page.getByRole('option').allTextContents()
console.log('Available threads:', threads)
// Check API response
await page.route('**/api/v1/threads*', route => {
console.log('Threads API called:', route.request().url())
route.continue()
})Test Pollution
Symptoms:
- Tests fail when run together but pass individually
- Unexpected data from previous tests
Solutions:
- Use
test.beforeEach()for fresh setup - Randomize test data (use Faker)
- Clean up test data in
test.afterEach() - Run tests with
--workers=1to isolate
Performance Issues
Tests Running Slowly
Common causes:
- Excessive waits (use explicit conditions, not timeouts)
- Not enough parallelization (increase
--workers) - Headed mode enabled (use headless for speed)
- Tracing enabled (disable for normal runs)
Optimization:
# Fast run (headless, parallel, no tracing)
pnpm e2e --workers=4
# Use storage state to skip login
# (already configured in fixtures)Timeout Errors
Increase timeout for slow operations:
// Per-test timeout
test('slow operation', async ({ page }) => {
test.setTimeout(60000) // 60 seconds
// Test code
})
// Per-assertion timeout
await expect(page.getByText('result')).toBeVisible({ timeout: 30000 })Debugging Tools
Playwright Inspector
Launch in debug mode:
pnpm e2e --debug
# Or add to specific test
await page.pause()Features:
- Step through test actions
- Inspect page state at each step
- Edit selectors interactively
- View console logs
Trace Viewer
Capture traces:
pnpm e2e --trace=onView traces:
npx playwright show-trace test-results/path-to-trace.zipTrace features:
- Timeline of all actions
- Screenshots at each step
- DOM snapshots
- Network activity
- Console logs
Headed Mode
Watch tests execute:
pnpm e2e --headedSlow down execution:
pnpm e2e --headed --slow-mo=1000 # 1 second delay per actionScreenshots
Automatic on failure:
- Screenshots saved to
test-results/ - Includes timestamp and test name
Manual screenshots:
await page.screenshot({ path: 'debug-screenshot.png', fullPage: true })Getting Help
Check Documentation
- E2E Testing Guide - Main testing documentation
- Playwright Docs - Official Playwright documentation
- Test Specs - Test scenario specifications
Enable Debug Logging
# Playwright API calls
DEBUG=pw:api pnpm e2e
# Browser console logs
DEBUG=pw:browser pnpm e2e
# All debug output
DEBUG=pw:* pnpm e2eCommon Commands
# Run single test file
pnpm e2e e2e/tests/comments.spec.js
# Run specific test by name
pnpm e2e --grep "add comment"
# Run in specific browser
pnpm e2e --project=chromium
# Run with UI mode (interactive debugging)
npx playwright test --ui
# Generate test code (Codegen)
npx playwright codegen https://localhost:5173For more information, see:

