Reach 100% line coverage without duplicating test suites - #569
Merged
Conversation
The coverage report was double-counting library code: preact.test.tsx copies packages/wouter/src/* into wouter-preact/src/ for the duration of the run, so every source file was measured twice — once fully exercised at its original path, once barely exercised as a copy. Excluding the temporary copies from coverage (react-deps.js, the only real preact-specific source, stays measured) lifts the total from 92.6% to 99.7% without a single new test. The remaining uncovered lines each get a targeted fix: - use-browser-location.js 72-85 (history monkey-patch): the wouter-preact copy loaded first and claimed the one-shot patch, so the original module skipped it. Preloading the module in setup.ts after happy-dom registration makes the original file own the patch again. - paths.js 32 (decodeURI fail-safe): one test navigating to a search string with a malformed escape sequence. - wouter-preact react-deps.js 43 (useSyncExternalStore shim re-render when the store mutates between render and layout effect): one test using a child layout effect, which runs before the parent's. Line coverage is now 100% and enforced via coverageThreshold in bunfig.toml. Bun applies the threshold per file, so it is set to 0.99: every source file must stay at 99%+ lines for bun test --coverage to exit 0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NA9Qh5EpmZKA9UZASuQfEq
|
|
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.
The coverage report was double-counting library code: preact.test.tsx
copies packages/wouter/src/* into wouter-preact/src/ for the duration of
the run, so every source file was measured twice — once fully exercised
at its original path, once barely exercised as a copy. Excluding the
temporary copies from coverage (react-deps.js, the only real
preact-specific source, stays measured) lifts the total from 92.6% to
99.7% without a single new test.
The remaining uncovered lines each get a targeted fix:
copy loaded first and claimed the one-shot patch, so the original
module skipped it. Preloading the module in setup.ts after happy-dom
registration makes the original file own the patch again.
string with a malformed escape sequence.
when the store mutates between render and layout effect): one test
using a child layout effect, which runs before the parent's.
Line coverage is now 100% and enforced via coverageThreshold in
bunfig.toml. Bun applies the threshold per file, so it is set to 0.99:
every source file must stay at 99%+ lines for bun test --coverage to
exit 0.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01NA9Qh5EpmZKA9UZASuQfEq