Skip to content

Playwright test reliability#32

Merged
kentcdodds merged 6 commits into
mainfrom
cursor/playwright-test-reliability-e1ed
Jan 30, 2026
Merged

Playwright test reliability#32
kentcdodds merged 6 commits into
mainfrom
cursor/playwright-test-reliability-e1ed

Conversation

@kentcdodds
Copy link
Copy Markdown
Member

@kentcdodds kentcdodds commented Jan 30, 2026

Summary

This PR significantly improves the reliability of Playwright E2E tests by:

  • Configuring Playwright for Stability: Increased timeouts, added screenshot/video capture on failure, enabled retries, and enforced serial execution in CI for better database isolation.
  • Enhancing Test Utilities: Introduced retryDbOperation for transient database errors, improved waitFor utility with longer defaults, and added explicit fixture cleanup functions.
  • Improving Test Logic: Updated individual tests with explicit waitFor visibility checks, waitForLoadState after navigation, increased assertion timeouts, and comprehensive fixture cleanup at test start/end.
  • Ensuring Clean State: Implemented a global setup to clear all test fixtures before runs and integrated Prisma consent for CI database setup.

These changes aim to reduce flakiness, provide better debugging information for failures, and ensure test isolation.

Test Plan

All 14 Playwright E2E tests passed locally with CI=true npx playwright test.

Checklist

  • Tests updated
  • Docs updated

Screenshots

N/A


Open in Cursor Open in Web


Note

Low Risk
Changes are confined to test configuration/utilities and E2E specs, with no production runtime impact; main risk is longer CI runtimes or masking legitimate timing issues via higher timeouts.

Overview
Improves Playwright E2E reliability by loosening timeouts/retries and adding better CI diagnostics: higher global/expect/action/navigation timeouts, CI-only serial execution with 1 worker, more retries, CI github reporter, and a longer webServer startup timeout.

Adds fixture/database isolation utilities and setup: a new Playwright globalSetup clears tests/fixtures and runs DB setup; mocks gain deleteFixture/deleteText, longer retry defaults, and more informative waitForText/waitFor timeouts. Test helpers now retry transient Prisma ops (retryDbOperation) and automatically clean text fixtures around login/insertNewUser, while multiple E2E specs add explicit domcontentloaded/visibility waits and increased assertion timeouts (including a much longer scheduled-send test).

Written by Cursor Bugbot for commit 20d457e. This will update automatically on new commits. Configure here.

cursoragent and others added 2 commits January 30, 2026 03:49
- Increase timeouts in playwright.config.ts (test: 60s, expect: 15s, action: 15s, navigation: 30s)
- Add screenshot/video capture on failure/first retry for debugging
- Add global setup to clean fixtures directory before test runs
- Add retries (3 in CI, 1 locally) for flaky test recovery
- Run tests in series in CI for better database isolation
- Increase webServer startup timeout to 120s

- Add retryDbOperation utility for transient database errors
- Add fixture cleanup for phone numbers in test fixtures
- Increase waitFor default timeout to 10s with better polling intervals
- Add waitForPageStable and navigateAndWait helpers

- Improve mock utils with increased retry attempts and timeouts
- Add deleteText and deleteFixture utilities for cleanup

- Add explicit waitFor visibility checks before interactions
- Add waitForLoadState after navigation
- Increase assertion timeouts
- Clean up stale fixtures at test start and end
- Better error messages for waitForText calls

Co-authored-by: me <me@kentcdodds.com>
- Fix await in non-async callback by pre-computing password hash
- Add PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION env var for CI database setup

Co-authored-by: me <me@kentcdodds.com>
@cursor
Copy link
Copy Markdown

cursor Bot commented Jan 30, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@kentcdodds kentcdodds marked this pull request as ready for review January 30, 2026 03:56
Comment thread tests/playwright-utils.ts Outdated
Comment thread tests/playwright-utils.ts Outdated
- Fix cleanupFixturesForPhone to use filenamify() consistently with fixture creation
- Remove unused waitForPageStable and navigateAndWait helper functions
@cursor
Copy link
Copy Markdown

cursor Bot commented Jan 30, 2026

Bugbot Autofix resolved both of the 2 bugs found in the latest run.

  • ✅ Fixed: Fixture cleanup uses wrong string transformation for matching
    • Updated cleanupFixturesForPhone to use filenamify() consistently with how fixtures are created, ensuring correct file matching.
  • ✅ Fixed: Exported helper functions added but never used
    • Removed the unused waitForPageStable and navigateAndWait functions that were never called in the codebase.

Use separate final variables instead of nullish coalescing assignment
to properly narrow types for phoneNumber and username

Co-authored-by: me <me@kentcdodds.com>
Comment thread tests/playwright-utils.ts Outdated
Comment thread tests/playwright-utils.ts Outdated
Comment thread tests/playwright-utils.ts Outdated
@cursor
Copy link
Copy Markdown

cursor Bot commented Jan 30, 2026

Bugbot Autofix resolved all 3 of the 3 bugs found in the latest run.

  • ✅ Fixed: Prefix matching may delete unrelated phone fixtures
    • Changed prefix matching to exact file matching using file === targetFile to prevent deletion of unrelated phone fixtures.
  • ✅ Fixed: Duplicate waitFor functions in two test utility files
    • Removed duplicate waitFor function from playwright-utils.ts and imported it from mocks/utils.ts instead.
  • ✅ Fixed: Unused Page type import in playwright-utils
    • Removed the unused type Page import from the @playwright/test import statement.

Comment thread tests/playwright-utils.ts
@cursor
Copy link
Copy Markdown

cursor Bot commented Jan 30, 2026

Bugbot Autofix resolved the bug found in the latest run.

  • ✅ Fixed: Redundant cleanupFixturesForPhone duplicates existing deleteText utility
    • Replaced the redundant cleanupFixturesForPhone function with the existing deleteText utility from mocks/utils.ts, eliminating code duplication.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread tests/mocks/utils.ts
} catch {
// Ignore errors if file doesn't exist
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported function deleteFixture is never imported externally

Low Severity

The deleteFixture function is exported but never imported anywhere in the codebase. It's only used internally by deleteText within the same file. This function doesn't need to be exported and could be a private helper function instead.

Fix in Cursor Fix in Web

@kentcdodds kentcdodds merged commit 858a1ec into main Jan 30, 2026
6 checks passed
@kentcdodds kentcdodds deleted the cursor/playwright-test-reliability-e1ed branch January 30, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants