Effect stops listening after service error in NgRx Effects integration test
0 reputation · 25 Mar 2024, 00:58 UTC
Goal is to validate an NgRx Effect integration without importing production credentials, environment files, or real network endpoints. The effect is the boundary between intent actions and a gateway service, and tests should assert the observable contract of success and failure actions using a mocked Actions stream and an overridden API configuration token.
Constraints are to keep the test free of real base URLs and tokens by overriding the injection token that provides API configuration, and to use provideMockActions with a fake backend for the service call. The documented failure condition is that an effect can stop listening or emit no failure action when error handling is misplaced in the operator chain.
Retry policy for transient failures remains an unresolved design decision for the team. The test needs to encode the chosen behavior explicitly without relying on production wiring.
Which observable shape should a fake gateway return to simulate a service error while keeping the outer actions stream alive? Should the test assert emission of a typed failure action and continued subscription for a subsequent dispatch? Is retry intended to be implemented inside the effect operator chain or delegated to a caller?