Skip to content

test(preact): make navigation test cover re-renders in any file order - #574

Merged
molefrog merged 1 commit into
mainfrom
claude/sweet-meitner-es0omg
Sep 29, 2026
Merged

molefrog merged 1 commit into
mainfrom
claude/sweet-meitner-es0omg

Conversation

@molefrog

@molefrog molefrog commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Fixes the coverage failure on main after #573: the Preact navigation test only exercised its subscription when other test files happened to run afterward.

Render inside act(), assert that the route updates after navigation, and unmount afterward. This makes coverage independent of test order and catches broken Preact subscriptions. No runtime changes.

Verified with Bun 1.4.2: 100% coverage in CI, reverse, and default file order; 25 randomized orders passed. Disabling the subscription now fails the test. Type checks, lint, formatting, and the test with Preact 11 RC also passed.

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MEaKcdDoavE2k3pprs23yq
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions

Copy link
Copy Markdown

size-limit report 馃摝

Path Size
packages/wouter/src/index.js 2.29 KB (0%)
packages/wouter/src/use-browser-location.js 555 B (0%)
packages/wouter/src/memory-location.js 729 B (0%)
packages/wouter/src/use-hash-location.js 720 B (0%)
packages/wouter-preact/src/index.js 2.18 KB (0%)
packages/wouter-preact/src/use-browser-location.js 488 B (0%)
packages/wouter-preact/src/use-hash-location.js 645 B (0%)
packages/wouter-preact/src/memory-location.js 664 B (0%)

@molefrog
molefrog merged commit 0794c29 into main Sep 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants