P
Prisma•2w ago
nikxda

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?
No description
5 Replies
Prisma AI Help
Prisma AI Help•2w ago
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!
Nurul
Nurul•2w ago
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?
nikxda
nikxdaOP•2w ago
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
Nurul
Nurul•2w ago
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 🤔
nikxda
nikxdaOP•2w ago
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)

Did you find this page helpful?