Mocking Prisma with Bun
Hi, I'm trying to mock Prisma Client with Bun. I followed the Unit Testing guide which uses jest-mock-extended, but when I try to use it with bun I get the error seen in the screenshot. Unfortunately Google is zero help on this. Has anybody successfully mocked Prisma Client with Bun?
5 Replies
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into
#ask-ai
for a quick spin!Hey 👋
I haven't come across this error before. If I understand correctly, everything works as expected with node, but when you try to use Bun, you run into this error, right?
Hey Nurul, thanks for jumping in. I haven't tried with plain Node as setting that up would be quite a bit of pain in terms of getting TypeScript and imports to work in our project. Unfortunately we have settled on Bun, so it's what I have to work with. But I do think this is a Bun or setup issue, not a Node one
I assume you are running Buns inbuilt test runner,
From their docs:
Bun aims for compatibility with Jest, but not everything is implemented. To track compatibility, see this tracking issue.https://github.com/oven-sh/bun/issues/1825 I think this could be a compatibility issue 🤔
Yeah, I am aware. I'm not sure how compat issues would lead to this error but I can't find any more details on the error in the Jest codebase either... so it might be Bun. Is there another way of deep mocking Prisma with the Bun test runner?
(apart from rolling my own)