fix: retry flaky Playwright integration/e2e tests on CI - #1289
Merged
Conversation
The integration suite drives the whole app against a single-process `vite preview` server with mock APIs served in-process. Under CI's parallel worker load the shared server intermittently mishandles a request — e.g. the vault-datasets API-key mock rejecting a *valid* key under contention — producing spurious failures unrelated to any code change. Reproduced locally under `--workers=4` stress (~4% per-test). Add `retries: process.env.CI ? 2 : 0` (shared `ciRetries` helper) so these transient blips self-recover on CI, while keeping 0 retries locally so real failures surface immediately. Validated: the same stress that failed 7/176 runs passes cleanly with retries enabled. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Why
PR #1288's CI repeatedly failed on 3 tests in
tests/integration/trading-view/vaults/datasets.test.ts(the vault-datasets API-key flow) — a different overlapping subset each run — while they pass reliably locally. This is long-standing: the CI workflow itself notes (since 2023) that the integration suite is "too flaky and do not pass on CI at all", andbuild'sneeds: testis commented out because of it.Root cause (reproduced, not guessed): the integration suite drives the whole app against a single-process
vite previewserver whose APIs are served by an in-process mock middleware (vite-plugin-mock-dev-server). Under the parallel-worker load CI applies, that shared server intermittently mishandles a request. The captured failure snapshot shows the form displaying "The API key is not valid" after submitting the valid key — i.e. the mock returned 401 for a correct key under contention. It's environmental, not an app bug.Reproduced locally by running the file under
--workers=4 --repeat-each=8: 7/176 runs failed with the exact CI symptom. Re-running the identical stress with--retries=2: 0 hard failures (all flakes self-recovered).The integration/e2e Playwright configs had no
retriesset, so CI ran with 0 retries — any single transient blip failed the whole job.Lessons learnt
--workers=N --repeat-each=Mbefore suspecting app code.waitForResponsein the test would not have fixed the 401 case; retrying does.Summary
ciRetriesconstant intests/helpers.ts(process.env.CI ? 2 : 0) with a comment documenting the root cause.retries: ciRetriesinto all three Playwright configs:tests/integration/playwright.config.ts,tests/integration/private.playwright.config.ts, andtests/e2e/playwright.config.ts.🤖 Generated with Claude Code