You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f9f6fee
Browse filesBrowse the repository at this point in the historyBrowse files
tests: faster local e2e runs, fix three CI flakes (#3445)
I looked into speeding up local e2e runs and fixing some flakes we keep
seeing in CI. Not sure whether the speedup is worth it here, but it is
pretty big for the occasional local full suite run.
### Speedup
A Playwright [trace](https://playwright.dev/docs/trace-viewer) is a
recording of a test run that you open in the trace viewer: a DOM
snapshot before and after each action, plus screenshots, network
requests and console output. Locally we ran with `trace:
'retain-on-failure'`, which records a trace for every test and throws it
away when the test passes. Local runs now default to `off`; pass
`--trace retain-on-failure` when chasing a flake (noted in AGENTS.md and
the `debug-e2e` skill). CI keeps `on-first-retry`, which only records on
retries.
Wall-clock time on my 14-core Mac, Chrome only, 9 workers (the local
default), with tracing on and off runs interleaved. Times include
starting the dev server.
| Run | Runs each | Tracing on | Tracing off | Saved |
| ---------------------------------------------------- | --------- |
------------------------- | --------------------------- | ----- |
| One test (`can resize a failed or stopped instance`) | 5 | 12.0–14.2 s
(median 12.1) | 11.3–12.1 s (median 11.5) | ~5% |
| `instance.e2e.ts` (19 tests) | 3 | 21.8–22.9 s (median 22.7) |
19.4–20.2 s (median 20.2)\* | ~11% |
| Full suite (429 tests) | 2 | 236.5–245.3 s | 182.7–183.0 s | ~24% |
\* The range leaves out a third tracing-off run that took 44.6 s. The
median includes it.
I also considered running e2e against the production build. Every test
starts in a fresh browser context, so every page load refetches every
unbundled module from the Vite dev server. The production build is
faster for the full suite: on the Mac, main took 210 s and the
production build with tracing off took 154–156 s (two runs each, 402
tests). But the build runs before every invocation, so a single test got
slower, 7.9 s against 6.2 s on the dev server, and the break-even is
probably somewhere around 20–30 tests. Locally we mostly run one file or
one test, and CI runs the full suite. Supporting both dev and prod
servers also meant some noisy fixes for 13 tests that assumed the dev
server, across 10 files, and e2e would no longer run with StrictMode
double effects or React dev warnings. It could still make sense for CI
later.
### Flakes
- **`support-bundles › bundle deleted mid-view 404s`** failed on Firefox
in 3 of the last 11 CI runs, once on [all three attempts on
main](https://github.com/oxidecomputer/console/actions/runs/43102126272).
It has 3 s to see the bundle in `destroying`, and the toast helpers
slept 1 s after every dismissal (added in #1832, nobody knew why). They
now wait for the toast to leave the DOM. On Firefox it went from 5/10
passing to 10/10, and 10 toast-heavy specs showed no new failures.
- **`vpcs › can nav to VpcPage from /`** failed its first attempt on
Chrome in 7 of the last 11 CI runs. The `VPCs` link locator also matched
the `project-no-vpcs` link in the projects table, still on screen on a
slow runner. With `exact: true` and Chrome's CPU throttled 2x, it went
from 0/20 passing to 20/20.
- **`route-announcer › route announcer`** failed on Firefox in 7 of the
last 11 CI runs. react-aria removes each announcement after 7 s, before
a slow runner gets to the assertion. The test now records announcements
as they appear. With a 7.5 s pause added after a nav, the old test
failed 5/5 on Firefox and the new one passed 5/5.
- Serial console (`theme.e2e.ts:99`), fixed in app/msw-mock-api.ts.
- Cause: the mock stream slept after each of 160 boot log lines, so on a
busy runner every late timer added to the total. With Firefox held to
the slow cores, the stream took 19 s instead of 4.8 s, against a 15 s
timeout.
- Fix: each line is now due at a fixed offset from the start, and late
lines go out together.
- Result: 0/6 → 6/6 with one worker on slow cores. With three workers it
was 0/9 → 3/9, where page load alone took about 10 s, which is harsher
than CI.
- CI history: flaked in 11 of the last 120 runs, all Firefox.
- Scroll restore (`scroll-restore.e2e.ts:12`), fixed in
test/e2e/utils.ts.
- Cause: the test scrolled before web fonts loaded. When the fonts
arrived, the h1 above the viewport resized and scroll anchoring moved
scrollY from 143 to 140.5, which then got saved and restored.
- Fix: the scrollTo helper waits for document.fonts.ready first, which
covers all its callers.
- Result: 31/40 → 40/40. The unmodified spec didn't fail locally in 60
runs, so this was reproduced with a copy of the spec plus a no-op init
script under heavy CPU load.
- CI history: the most frequent of the three, 32 Firefox runs and 2
Chrome out of 120.
- Not fixed: a rarer failure in the same test ("expected 190, got 143",
once in CI and twice locally). The subagent's unconfirmed guess is that
useScrollRestoration skips saving when a nav has cached data.
Copy file name to clipboardExpand all lines: .claude/skills/debug-e2e/SKILL.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ Prefer narrowing with `-g` and `--project` first, then increase `--repeat-each`
69
69
70
70
### 3. Analyze failure artifacts
71
71
72
-
When tests fail, Playwright saves traces and error context:
72
+
When tests fail, Playwright saves error context. Traces are off by default in local runs because recording them slows the suite; add `--trace retain-on-failure` to the test command to keep a trace for each failed test.
73
73
74
74
```bash
75
75
# View error context (page snapshot at failure time)
Copy file name to clipboardExpand all lines: AGENTS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@
47
47
- Treat Vitest browser specs as small e2e tests: query by accessible role, label, or visible text and use retrying browser matchers. Avoid selectors coupled to CSS classes or internal DOM structure; inspect layout or computed styles only when the behavior has no semantic representation.
48
48
- For sweeping styling changes, coordinate with the visual regression harness and follow `test/visual/README.md` for the workflow.
49
49
- Fix root causes of flaky timing rather than adding `sleep()` workarounds in tests.
50
-
- When an intermittent browser or E2E failure does not reproduce under normal repetition, retry under controlled CPU contention before concluding it is CI-only. Keep the load bounded so the browser and test runner can still make progress, enable failure-only traces when available, and use a shell trap to clean up every churn process.
50
+
- When an intermittent browser or E2E failure does not reproduce under normal repetition, retry under controlled CPU contention before concluding it is CI-only. Keep the load bounded so the browser and test runner can still make progress, enable failure-only traces (`--trace retain-on-failure`, off by default locally), and use a shell trap to clean up every churn process.
51
51
- Local Playwright runs write a compact plain-text report to `.e2e-logs/` (gitignored, one timestamped `.log` per run, last 10 kept) via the custom reporter at `test/e2e/compact-reporter.ts`. Top line is `status: ... total=N passed=N ...`; each failure is a `── UNEXPECTED|FLAKY file:line title` block followed by the error (ANSI stripped). Latest run: `ls .e2e-logs | tail -1` — Read it directly, no parsing needed.
0 commit comments