Open xxjjnn opened 1 year ago
I changed setup-prisma.js
to:
jest.mock("./lib/prisma", () => {
const { jestPrisma } = require('@quramy/jest-prisma');
return {
prisma: jestPrisma.client,
};
});
new error!
TypeError: Cannot read properties of undefined (reading 'client')
Try this:
const mockJestPrisma = jestPrisma
jest.mock("./src/client", () => ({
prisma: mockJestPrisma.client,
}))
When you mock a module this call is hoisted which means that locally declared variables might not be available inside the mock. However, when you a variable name starts with mock
then jest
allows it.
In the documentation it says
When running
npm test
it says:jest.config.js
looks like:It seems there is a problem setting up
jestPrisma
to be accessible from the 'setup.prisma.js' file?I tried adding
const { jestPrisma } = require('@quramy/jest-prisma');
to the top of 'setup.prisma.js' and it still gave the same error.