Type Error When Providing NotificationApi to UserApi in Test Suite

I have a similar issue to the one i effect-beginners-šŸš€ The issue now is that when providing the NotificationApi to the UserApi , vscode will complain saying that:

Type '"NotificationRepo"' is not assignable to type '"UserApi"'.


I guess I am a little confused here how to setup my test suite properly such that I only need to worry about mocking my NotificationApi and not care about the dependencies it brings with it.


const mockSendNotification = vi.fn();

layer(
  Layer.mergeAll(UserApi.Live.pipe(Layer.provide(
    // I tried piping the NotificationRepo layer here but it blew up. I also don't want to have to provide those details.
    makeTestLayer(NotificationApi)({
      // eslint-disable-next-line @typescript-eslint/no-unsafe-return
      sendNotification: () => mockSendNotification()
    }),
  ))),
)("userApi test suite", (it) => {
  beforeEach(() => {
    mockSendNotification.mockClear();
  });

  it("should send notification after creation", async ({ run }) => {
    mockSendNotification.mockReturnValueOnce(Effect.succeed({
      status: "ok",
      devices: ["device1", "device2"]
    }))
  // Here is where the error shows: Type '"NotificationRepo"' is not assignable to type '"UserApi"'.
  yield* userApi.createUser({
      name
    });

    expect(mockSendNotification).toHaveBeenCalledTimes(1);
  });

// The makeTestLayer functon comes from effect-http-play: https://github.com/tim-smart/effect-http-play/blob/main/src/lib/Layer.ts


šŸ¤”
Was this page helpful?