having issues running tests with prisma mocked in...
# prisma-client
k
having issues running tests with prisma mocked in jest test, posted related info in the discussion on github: https://github.com/prisma/prisma/discussions/7084#discussioncomment-2683574
n
Hey kevin 👋 Are you having these issues in latest version of
@prisma/client
and
jest-mock-extended
?
k
i will re-test this week and let you know
Copy code
➜ yarn why prisma      
yarn why v1.22.19
[1/4] �  Why do we have the module "prisma"...?
[2/4] �  Initialising dependency graph...
[3/4] �  Finding dependency...
[4/4] �  Calculating file sizes...
=> Found "prisma@3.14.0"
Copy code
➜ yarn why jest-mock-extended
yarn why v1.22.19
[1/4] �  Why do we have the module "jest-mock-extended"...?
[2/4] �  Initialising dependency graph...
[3/4] �  Finding dependency...
[4/4] �  Calculating file sizes...
=> Found "jest-mock-extended@2.0.6"
prisma mock looks like this:
Copy code
import prisma from "@db/prisma";
import type { PrismaClient } from "@prisma/client";
import type { DeepMockProxy } from "jest-mock-extended";
import { mockDeep, mockReset } from "jest-mock-extended";

jest.mock("@db/prisma", () => ({
  __esModule: true,
  default: mockDeep<PrismaClient>(),
}));

beforeEach(() => {
  mockReset(prismaMock);
});

export const prismaMock = prisma as unknown as DeepMockProxy<PrismaClient>;
and the error I get looks like this:
Copy code
● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'mockDeep')

       6 | jest.mock("@db/prisma", () => ({
       7 |   __esModule: true,
    >  8 |   default: mockDeep<PrismaClient>(),
         |                    ^
       9 | }));
      10 |
      11 | beforeEach(() => {

      at utils/testing/prisma-mock.ts:8:20
      at Object.<anonymous> (utils/testing/prisma-mock.ts:1:32)
      at Object.<anonymous> (utils/aws.test.ts:5:51)