-
Notifications
You must be signed in to change notification settings - Fork 106
Description
Here is the repo I created (based off of the Prisma docs)
I've been having difficulty trying to get tests passing per the resources provided in the docs. There is a reference to resolve the circular reference issue appearing for the context (and maybe also singleton) solutions. However, there is no instruction within the docs that shows how to configure the .jest.config.js
to leverage the .tsconfig
file.
The following solution resolves that:
// jest.config.js
module.exports = {
clearMocks: true,
preset: "ts-jest",
testEnvironment: "node",
setupFilesAfterEnv: ["<rootDir>/singleton.ts"],
globals: {
"ts-jest": {
tsconfig: "./.tsconfig",
// set global config for ts-jest
},
},
};
with that update to jest.config.js
in place, the following error goes away and the tests pass:
However, the error still persists within the file itself.
the following provides a bandaid solution in the event that a linter is pipeline is getting jammed up.
// @ts-ignore
prismaMock.user.create.mockResolvedValue(user);
It's also worth noting, the solution used above evidently works without having "strictNullChecks": true
within .tsconfig