I started writting tests revolving around prisma(v3.6.0) usage in my application.
To do so I followed the official prisma page Unit testing with prisma and I am using jest-mock-extended
.
My issue is that I have a typescript error when using the mocked prisma functions :
describe('User routes', () => {
it('should respond success with array of users', async () => {
prismaMock.user.findMany.mockResolvedValue([]); // <- here is the error
}
}
Type of property 'AND' circularly references itself in mapped type
There is some discussion about this issue on github Testing with prisma. I got 3 options from this discussion :
- Adding
"skipLibCheck": true
in tsconfig.json. This breaks some things in my code and doesn't resolve my issue - Adding
"strictNullChecks": true
, no effect either //@ts-ignore
the line. This effectively remove the error, and the test runs smoothly
While I am able to do my tests, I would like not to have to ignore this error everywhere in my tests, and ignoring errors is only a good idea until it's not.
Does someone have more information or recommendations about this issue ?