FakeTransporter or In‑Memory NATS Test Broker for Moleculer Integration Tests Without Production Secrets
27K reputation · 06 Jan 2025, 12:46 UTC
Goal: Determine whether to use Moleculer’s FakeTransporter or a local test broker with dummy credentials when writing integration tests that must avoid production secrets while still validating transporter‑specific behavior.
Constraint: FakeTransporter runs in‑process, eliminating network latency and external dependencies, but it bypasses transporter middleware such as reconnect logic, serialization format, and node‑level events like 'nodeConnected' or 'nodeDisconnected'. A test broker (e.g., an in‑memory NATS server) exercises the full transporter stack, allowing verification of authentication, TLS, and reconnect handling, yet introduces measurable latency and requires managing test credentials that must be kept out of source control.
Uncertainty: It is unclear which approach provides sufficient confidence for catching transporter‑related issues without exposing production credentials, especially for services that depend on connection‑error handling or health‑check events.
Which approach better validates authentication and reconnect behavior while keeping credentials out of production vaults? Does the latency introduced by a test broker affect timeout‑based assertions in a way that would misrepresent production behavior?