getting a typescript error when trying to use drizzle.mock()
I'm trying to mock my drizzle driver for some unit tests. I'm using
drizzle.mock()
. When I pass it into the function that takes it, I get the following error:
I tried to modify the property, to have a null pool, but I get another error telling me that type Pool isn't compatible with the prop's type.
how do I mock the driver? I've been at it for the past couple of days and am super confused 😖4 Replies
I have been using
import { type NeonHttpDatabase as DbClient } from "drizzle-orm/neon-http";
in my project. Other work that I've done figuring out how to use the generic types is mentioned here - https://discord.com/channels/1043890932593987624/1392559056572645388/1393275780330426450thanks, I'll check that out. I am, however, looking for a way to completely mock out the DbClient. not sure how this would achieve that
If you use
Record<string, unknown>
it should work, that's what they're doing in all the mock functions - https://github.com/drizzle-team/drizzle-orm/blob/ac1dcd9d1c4b8f171479af4a5dd731db1e164f58/drizzle-orm/src/node-postgres/driver.ts#L145
e.g. NodePgDatabase<Record<string, unknown>>
thx I'll give it a try