Fix intermittent browser test failures caused by parallel execution #226
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nidde/parenting-tool!226
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "copilot/fix-parallel-browser-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Browser tests run against a shared SQLite file — parallel execution causes
RefreshDatabasein one process to truncate the DB mid-request in another, producing race conditions and 5000ms timeouts. Long fixedwait(N)calls are also fragile under any system load.Description
Two root causes, two fixes:
1. Remove
--parallelfrom browser test CI commandSQLite + parallel
RefreshDatabaseis fundamentally unsafe. Sequential execution eliminates the contention entirely.2. Replace large fixed
wait()calls withwaitForEvent('networkidle')after form submissionsThe
Pest\Browser\Api\Webpageclass only exposeswait(seconds),waitForEvent(state), and the deprecatedwaitForText()— there is nowaitFor(selector)method. Post-submission waits have been replaced withwaitForEvent('networkidle')to wait for actual network state instead of guessing a time. Shortwait(0.5)/wait(1)pauses are retained after FAB clicks to allow Vuetify animations to complete.Applied across 8 test files:
TaskBoardTest,AnnualEventsTest,PurchasesPageTest,MortgageWorkflowTest,CreditCardWorkflowTest,DashboardCardsTest,ToastNotificationTest,FrontendTransactionFilteringTest.Type of Change
Testing
Code Quality
CI/CD Checks
Additional Notes
The trade-off for removing
--parallelis longer total browser test runtime. Given that browser tests are I/O-bound (real browser + HTTP server) rather than CPU-bound, the parallelism gain was marginal while the flakiness cost was significant. Thewait(2)inPwaTest.php(service worker deferral) was intentionally left unchanged — it is a timer-driven browser API, not a network event.Comment
@coderabbitai helpto get the list of available commands and usage tips.@copilot
FAILED Tests\Browser\IAnnualEvents\AnnualEventsTest > `Annual Eve… Error
Call to undefined method Pest\Browser\Api\Webpage::waitFor()
at tests/Browser/I-AnnualEvents/AnnualEventsTest.php:60
56▕
57▕ visit('/calendar/annual-events')
58▕ ->assertSee('Original Name')
59▕ ->click('#annual-event-'.$event->id.'-edit')
➜ 60▕ ->waitFor('#annual-event-form-name')
61▕ ->clear('#annual-event-form-name')
62▕ ->fill('#annual-event-form-name', 'Updated Name')
63▕ ->click('#annual-event-form-submit')
64▕ ->waitForEvent('networkidle')
Tests: 8 failed, 71 passed (276 assertions)
Duration: 159.71s
Remember that while we're using Playwright, it is through PEST 4 Browser Tests.
Fixed in
d66b723.waitFor(selector)doesn't exist onPest\Browser\Api\Webpage— the API only provideswait(seconds),waitForEvent(state), and the deprecatedwaitForText(). Replaced allwaitFor('#selector')calls withwait(0.5)/wait(1)to restore the original animation pause timing, while keeping thewaitForEvent('networkidle')calls after form submissions (those are valid and more reliable than fixed waits).