Skip to content

Reach 100% line coverage without duplicating test suites - #569

Merged
molefrog merged 1 commit into
v3from
claude/test-coverage-99-percent-9nstya
Aug 10, 2026
Merged

Reach 100% line coverage without duplicating test suites#569
molefrog merged 1 commit into
v3from
claude/test-coverage-99-percent-9nstya

Conversation

@molefrog

Copy link
Copy Markdown
Owner

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

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
@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.22 KB (0%)
packages/wouter/src/use-browser-location.js 523 B (0%)
packages/wouter/src/memory-location.js 853 B (0%)
packages/wouter/src/use-hash-location.js 720 B (0%)
packages/wouter-preact/src/index.js 2.12 KB (0%)
packages/wouter-preact/src/use-browser-location.js 460 B (0%)
packages/wouter-preact/src/use-hash-location.js 646 B (0%)
packages/wouter-preact/src/memory-location.js 794 B (0%)

@molefrog
molefrog merged commit e3bf425 into v3 Aug 10, 2026
2 checks passed
@molefrog
molefrog deleted the claude/test-coverage-99-percent-9nstya branch August 10, 2026 17:15
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