marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
839 stars 57 forks source link

Doesn't mock special fn in prisma package #108

Open hadeelfouad opened 1 year ago

hadeelfouad commented 1 year ago

Tried the following code to mock my PrismaClient using JavaScript

import { PrismaClient } from '@prisma/client';
import { mockDeep } from 'jest-mock-extended';

export const createDatabase = () => {
  return mockDeep(PrismaClient.prototype);
}

And it was able to successfully mock all models functions but not any functions starting with $ (for example $transaction, $on, etc.) it still calls the real function even though the PrismaClient is a MockObject.