Effect CommunityEC
Effect Community8mo ago
7 replies
Benjamin

Mocking the `HttpApiClient` in the Effect Typescript library can be done by creating a mock imple...

Hi. Is there a way to mock HttpApiClient like in https://github.com/sukovanej/effect-http?tab=readme-ov-file#mock-client ? I'm currently struggling with how to mock the WithResponse type expected in the 'hi' function below.

class TestApiGroup extends HttpApiGroup.make('test').add( HttpApiEndpoint.get('hi', '/hello').addSuccess(S.String), ) {} class TestApi extends HttpApi.make('test').add(TestApiGroup) {} class ClientLive extends Effect.Service<ClientLive>()('ClientLive', { effect: HttpApiClient.make(TestApi), }) {} const mockClient = ClientLive.make({ test: { hi: () => Effect.succeed('hello'), }, });
Was this page helpful?