Testing

Prev Next

Polling Manager Testing

Polling Manager tests validate infrastructure contracts: lifecycle, dedup, overlap control, callback updates, and visibility behavior.

Run Tests

# PollingManager test suite (no coverage)
npx jest "src/__tests__/lib/internal/PollingManager/core/index.test.ts" --no-coverage

# PollingManager coverage for core implementation
npx jest "src/__tests__/lib/internal/PollingManager/core/index.test.ts" --coverage --collectCoverageFrom="src/lib/internal/PollingManager/core/index.ts"

Test Inventory

File Covers
core/index.test.ts immediate first poll, keyed dedup, ref-count lifecycle, overlap skip, pause/resume, visibility behavior, callback updates, stopAll, invalid input validation

Behavioral Coverage Checklist

The current suite validates:

  • immediate first poll on subscribe
  • one-task-per-key dedup semantics
  • no in-flight overlap for same key
  • lifecycle cleanup at last unsubscribe
  • terminal stop via shouldStop
  • error propagation and task continuity
  • global and per-key pause/resume
  • visibility behavior with and without documentRef
  • callback update invariants
  • snapshot-safe callback iteration during unsubscribe
  • input validation for required contract fields

Coverage Target

  • Branch coverage target: >= 90%
  • Current PollingManager core branch coverage: ~93% (latest local run)

Notes

  • Tests use fake timers and async flush patterns to make tick behavior deterministic.
  • The suite intentionally avoids module integrations at this stage; this is infrastructure-only validation.