Skip to content

test: improve branch coverage across watcher, client, compat, convert#106

Merged
zeevdr merged 1 commit into
mainfrom
feat/issue-102-coverage
May 28, 2026
Merged

test: improve branch coverage across watcher, client, compat, convert#106
zeevdr merged 1 commit into
mainfrom
feat/issue-102-coverage

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 28, 2026

Summary

  • Branch coverage was high on statements but lagged on branches in four files — the gaps included real async race conditions, untested retry code paths, and unreachable-but-documented runtime guards
  • Adds targeted tests that exercise the missing branches without introducing fragile infrastructure: spy-based converter mocking, fake timers for retry behavior, and TypeScript cast bypasses only where needed

Test plan

  • watcher.ts: asyncIterator race condition (stop during Promise constructor), reconnect timer cleared by stop(), stopped guards in subscribe/scheduleReconnect/reloadAndSubscribe, plain-Error wrapping in _loadInitial/_update, stop before start, undefined config response, undefined oldValue in processChange
  • client.ts: withRetryAndMap merges default codes when retryableCodes unset (line 514), idempotency key ternary branches for set/setMany/setNull/setNumber — verified via DEADLINE_EXCEEDED retry behavior
  • compat.ts: sparse array triggers ?? 0 guard in compare()
  • convert.ts: unsupported converter type reaches TypeMismatchError runtime guard (line 74)
  • npm run test:coverage — 255 tests pass; overall branch coverage 86.92% → 95.05%

Closes #102

Add tests targeting missing branches identified by v8 coverage:

- watcher.ts: asyncIterator race condition (stop during Promise
  constructor), reconnect timer cleared in stop(), subscribe/
  scheduleReconnect/reloadAndSubscribe stopped guards, plain-Error
  wrapping in _loadInitial/_update, stop before start, undefined
  config response in loadSnapshotForFields, undefined oldValue in
  processChange
- client.ts: withRetryAndMap line 514 (retry enabled with no custom
  retryableCodes), idempotency key ternary branch exercised for
  set/setMany/setNull/setNumber via DEADLINE_EXCEEDED retry behavior
- compat.ts: sparse array input to trigger ?? 0 guard in compare()
- convert.ts: unsupported converter type reaching TypeMismatchError
  runtime guard at line 74

Branch coverage: 86.92% → 95.05% overall
watcher: 75.94% → 92.4%, client: 84.5% → 95.77%
compat: 86.2% → 89.65%, convert: 95.31% → 96.87%

Closes #102

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr added this to the Beta Readiness milestone May 28, 2026
@zeevdr zeevdr added size: M Moderate — a day or two, clear scope priority: P2 Nice-to-have labels May 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zeevdr zeevdr merged commit 5146a94 into main May 28, 2026
14 checks passed
@zeevdr zeevdr deleted the feat/issue-102-coverage branch May 28, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P2 Nice-to-have size: M Moderate — a day or two, clear scope

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve branch coverage in watcher and client modules

1 participant