You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test runner: Vitest (pnpm test / pnpm dev for watch mode).
Coverage threshold: ≥ 80% lines/branches/functions using Vitest's built-in coverage (vitest run --coverage).
Test layout: mirror source tree under tests/, using *.test.ts for unit tests and *.spec.ts for integration flows.
Cross-Cutting Test Utilities
Create shared test helpers in tests/utils/:
HTTP mocks that simulate fetch/undici responses with programmable delays, aborts, and errors.
Queue-based mock for SNApiClient and LCD/RPC endpoints.
Stub implementations for SigningStargateClient exposing spyable simulate, broadcastTx, and signAndBroadcast.
WasmBridge shim that captures init calls and exposes deterministic layout outputs.
Enable fake timers (vi.useFakeTimers()) where retry/polling logic relies on timeouts.
Use vi.restoreAllMocks() / vi.resetModules() between tests to preserve isolation.
Diagnostic Logging via Spies
HttpClient.executeWithRetry(): vi.spyOn(HttpClient.prototype, "sleep") to log retry backoff intervals; wrap fetch mock to record attempts and emitted errors.
TaskManager.waitForCompletion(): inject spy on private sleep helper via prototype override to count poll iterations and capture timeout boundaries.
Emit structured console.info entries inside mocks (suppressed in assertions) when retries/polls occur; assert against snapshot of attempt metadata to validate behaviour.
Layer-Specific Plans
Internal Layer
HttpClient unit tests (tests/internal/http.test.ts):
Use dynamic import mock (vi.mock("rq-wasm", ...)) to assert lazy initialization, single-flight init, error reset on failure, and resetInstance() cleanup.
Confirm isInitialized() reflects state transitions.