Skip to content

Add contract tests against real grpc-js mock server#90

Merged
zeevdr merged 1 commit into
mainfrom
feat/contract-tests
May 24, 2026
Merged

Add contract tests against real grpc-js mock server#90
zeevdr merged 1 commit into
mainfrom
feat/contract-tests

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 24, 2026

Summary

  • The existing mock-based tests pass even when generated stub signatures change; this adds a second layer that exercises the actual proto encoding/decoding path end-to-end.
  • An in-process grpc-js server is spun up per test using the real generated service descriptors (ConfigServiceService, ServerServiceService), so any mismatch between the client's expectations and the wire format will be caught immediately.
  • The watch test drives the full ConfigWatcher lifecycle (snapshot via GetConfig + live updates via Subscribe) against a real streaming server.

Test plan

  • get() round-trips string, integer, and boolean values through proto serialization
  • get() raises NotFoundError when the server returns NOT_FOUND
  • set() / setNumber() / setBool() / setNull() send correctly typed proto values
  • setMany() sends a batch of mixed types in a single SetFields RPC
  • watch() loads the initial snapshot from GetConfig and propagates a change pushed through the Subscribe stream
  • watch() applies the field default when the field is absent from the snapshot
  • All 219 tests pass (npm test)
  • Biome lint + typecheck clean (npm run pre-commit)

Closes #58

Adds test/contract.test.ts with an in-process grpc-js server fixture
that exercises get, set, setMany, and watch RPCs through the actual
generated proto stubs. This catches signature drift that mock-based
tests cannot detect, closing the gap described in issue #58.

The fixture binds on port 0, registers per-test mutable handlers for
each RPC, and tears down cleanly after every test. The subscribe test
waits on an explicit Promise to avoid the race between watcher.start()
returning and the server-side streaming handler being invoked.

Closes #58

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

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zeevdr zeevdr merged commit 4ad953f into main May 24, 2026
14 checks passed
@zeevdr zeevdr deleted the feat/contract-tests branch May 24, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P1 Current milestone work size: M Moderate — a day or two, clear scope

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: contract test against a real grpc-js mock server

1 participant