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
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