test(preact): make navigation test cover re-renders in any file order - #574
Merged
Merged
Conversation
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
|
|
size-limit report 馃摝
|
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.
Fixes the coverage failure on
mainafter #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.