From 80d1e6d27d31a1cef068c84b14200af5a2b5972d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 29 Sep 2026 20:13:50 +0000 Subject: [PATCH] test(preact): make navigation test cover re-renders in any file order The "renders properly and reacts on navigation" test rendered outside act(), never asserted that the routes re-render and never unmounted. The location subscription callback in wouter-preact's react-deps.js was therefore only exercised by navigation in test files that happened to run afterwards. Whenever Bun ran preact.test.tsx last (as it currently does on the CI runner), react-deps.js dropped to 92.86% line coverage and the 0.99 per-file threshold failed the build with all tests passing. Render inside act() so the subscription is in place before the click, assert that the routes re-render with the new location, and unmount at the end so the app no longer leaks into later test files. The test now also fails if Preact components stop reacting to navigation, which the suite previously could not detect. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MEaKcdDoavE2k3pprs23yq --- packages/wouter-preact/test/preact.test.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/wouter-preact/test/preact.test.tsx b/packages/wouter-preact/test/preact.test.tsx index fa0fd4d7..f2868150 100644 --- a/packages/wouter-preact/test/preact.test.tsx +++ b/packages/wouter-preact/test/preact.test.tsx @@ -160,7 +160,8 @@ describe("Preact support", () => { ); }; - let node = render(, container); + // render inside `act` so that effects run and routes subscribe to location updates + act(() => render(, container)); const routesEl = container.querySelector('[data-testid="routes"]')!; const indexLinkEl = container.querySelector('[data-testid="index-link"]')!; @@ -190,6 +191,12 @@ describe("Preact support", () => { // Link accepts an `onClick` prop, fired after the navigation expect(fn).toHaveBeenCalledTimes(1); + + // subscribed routes re-render with the new location + expect(routesEl.textContent).toBe("Rolling Stones Best 100 Albums"); + + act(() => render(null, container)); + container.remove(); }); });