test: silence the 8,000-line CI test log — settle the router inside act, stub jsdom's no-ops, quiet the hub's counter feed in tests - #35
Conversation
…tub jsdom's no-ops, drop the hub's counter line from test output
The v0.1.0 release run's "Lint and test" step printed ~8,500 lines, ~95%
noise, in four classes. All of it reproduces locally under
vitest --reporter=verbose — the local default reporter hides console
output from passing tests, which is why the suite looked quiet here and
deafening in CI.
- 736 React act(...) warnings (~5,100 lines): every router-mounting
helper awaited router.load() and then rendered bare. Mounting
RouterProvider re-runs router.load() from Transitioner's mount effect,
and its continuations update the router stores a microtask after RTL's
synchronous act exits — one warning per mounted Match. Fixed at the
helpers: testing/render.tsx and the per-file mount helpers now render
inside `await act(async ...)`, so the post-mount load settles inside
act. Two component helpers (app-shell, update-notice) also emitted
welcome frames through the synchronous FakeSocket outside act; wrapped.
- 65 lines of jsdom "Not implemented: Window's scrollTo()": no-op stub in
test-setup.ts, same shape as the existing scrollIntoView stub.
- 8 lines of jsdom canvas getContext(): stubbed to return null, which is
what jsdom already returned after logging.
- 76 lines of the relay hub's {"evt":"channel_closed",...} JSON: that
line is the production Workers Logs counter feed and stays; a new
relay/test/setup.ts drops exactly that prefix from test output. The
counters test still passes — its console.log spy wraps the filter and
records the call either way.
Left noisy: 3 jsdom "navigation to another Document" lines, because the
only seam is jsdom's link-click navigation itself and suppressing that
would change what anchor-click tests prove; and workerd's own
"disconnected: read end of pipe was aborted" line in the relay run.
web: 998 tests, relay: 90 tests, all passing before and after.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Confirmed against this PR's own CI run (31334243256), same runner class as the v0.1.0 release run the profile was measured on:
One caveat worth naming: the first attempt of this run failed on |
The noise
The v0.1.0 release run's "Lint and test" step printed ~8,500 log lines, ~95% noise. Measured profile (run 31333105025):
act(...)warningsNot implemented: Window's scrollTo()getContext(){"evt":"channel_closed",...}JSONrelay/test/navigation to another DocumentNone of it showed locally because vitest's local default reporter hides console output from passing tests; CI's reporter prints it.
pnpm vitest run --reporter=verbosereproduces the CI view exactly (735 warnings locally vs CI's 736), which is what the before/after numbers below are measured with.The fixes, at their seams
act warnings — fixed in the render helpers, not per-test. Every router-mounting helper did
await router.load()and then a barerender(<RouterProvider .../>). MountingRouterProviderre-runsrouter.load()fromTransitioner's mount effect, and that call's continuations update the router stores a microtask after RTL's synchronousacthas exited — one warning per mounted Match, every mount. The helpers now render insideawait act(async () => ...)so the post-mount load settles inside act:web/src/testing/render.tsx(renderWithRouter— covers app-shell, session-table, page-header, devices, remote suites)web/src/router.test.tsx(renderAt,renderFleet,renderPicker,renderBare, one inline render)web/src/routes/sessions.test.tsx(mountSessions, plus oneattachedthat starts a navigation)web/src/routes/pair.test.tsx(renderPair,renderRelayPair)web/src/components/app-shell.test.tsx,web/src/components/update-notice.test.tsx: their helpers emittedwelcomeframes through the synchronousFakeSocketoutside act; wrapped.No global suppression:
IS_REACT_ACT_ENVIRONMENTuntouched, no console filtering of React output — an act warning from an app component still prints.jsdom no-ops — stubbed in
web/src/testing/test-setup.ts, in the same shape as the existingscrollIntoViewstub:window.scrollTobecomes a no-op,HTMLCanvasElement.prototype.getContextreturns thenulljsdom already returned after logging (the Devices no-canvas fallback test still pins that path).relay counter line — silenced in tests only. The
channel_closedline is production observability (relay/src/hub.ts,retireClient) and stays byte-identical. A newrelay/test/setup.tsdrops exactly that prefix at the printing edge; everything else the Worker logs still prints. The counters test (test/hub.test.ts, "logs the counters") passes unchanged — itsvi.spyOn(console, 'log')wraps the filter and records the call either way.Before / after
Measured with the reporter mode that matches CI's output (
--reporter=verbose, prints passing tests' console output):pnpm vitest run 2>&1 | wc -l)channel_closedlinesTests: web 56 files / 998 tests, relay 4 files / 90 tests — all passing before and after, none skipped.
pnpm run lint(tsc) clean in both;styles.build.test.tspasses (all new comments live in*.test.tsx/src/testing//relay/test/, outside the Tailwind scan perimeter).Deliberately left noisy
Not implemented: navigation to another Document— the only seam is jsdom's link-click navigation itself, and suppressing it (globalpreventDefault, anchorclickstubs) would change what the anchor-click tests prove: the router-Link-vs-plain-<a href>distinction intesting/render.tsxdepends on jsdom not navigating.disconnected: read end of pipe was abortedin the relay run — runtime-internal, not ours to filter.🤖 Generated with Claude Code