fix: eradicate flaky e2e test patterns across all spec files#23
Merged
fix: eradicate flaky e2e test patterns across all spec files#23
Conversation
Replace three root causes of test flakiness with deterministic alternatives:
1. Replace try/catch timer skip pattern with deterministic loop - the rest
timer always appears between sets (never after the last), so we can
handle it without try/catch and arbitrary 1s timeouts. Extract shared
completeAllSets() and completeRemainingSets() helpers.
2. Replace all waitForTimeout() calls with proper Playwright assertions
that wait for specific UI state changes (element visibility, text
content, CSS class changes) instead of arbitrary delays.
3. Replace waitForSelector('#rest-timer:not(.hidden)') CSS hacks with
Playwright's built-in toBeVisible() assertions.
Also remove CI retry (retries: 1) from playwright.config.ts since tests
should now be deterministic without needing retries as a safety net.
https://claude.ai/code/session_017FCubTmucERSuDiZi49Z4R
The PWA export/import test was racing with the app's seedDefaults()
initialization. waitForSelector('#app') resolves immediately since #app
is a static HTML element, but seedDefaults() is async and may still be
writing exercises to IndexedDB. If exportAll() runs before seedDefaults
finishes, the original snapshot has fewer exercises than the restored
one, causing the roundtrip comparison to fail.
Fix: wait for #start-workout-btn which only renders after seedDefaults()
and startRouter() complete, proving the app is fully initialized.
https://claude.ai/code/session_017FCubTmucERSuDiZi49Z4R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace three root causes of test flakiness with deterministic alternatives:
Replace try/catch timer skip pattern with deterministic loop - the rest
timer always appears between sets (never after the last), so we can
handle it without try/catch and arbitrary 1s timeouts. Extract shared
completeAllSets() and completeRemainingSets() helpers.
Replace all waitForTimeout() calls with proper Playwright assertions
that wait for specific UI state changes (element visibility, text
content, CSS class changes) instead of arbitrary delays.
Replace waitForSelector('#rest-timer:not(.hidden)') CSS hacks with
Playwright's built-in toBeVisible() assertions.
Also remove CI retry (retries: 1) from playwright.config.ts since tests
should now be deterministic without needing retries as a safety net.
https://claude.ai/code/session_017FCubTmucERSuDiZi49Z4R