我开始围绕应用程序中的 prisma(v3.6.0) 使用情况编写测试。
为此,我遵循了官方 prisma 页面使用 prisma 进行单元测试,并且我正在使用jest-mock-extended.
我的问题是,在使用模拟的 prisma 函数时出现打字稿错误:
describe('User routes', () => {
it('should respond success with array of users', async () => {
prismaMock.user.findMany.mockResolvedValue([]); // <- here is the error
}
}
Run Code Online (Sandbox Code Playgroud)
Type of property 'AND' circularly references itself in mapped type
Run Code Online (Sandbox Code Playgroud)
github Testing with prisma上有一些关于这个问题的讨论。我从这次讨论中得到了 3 个选择:
"skipLibCheck": true到 tsconfig.json。这破坏了我的代码中的一些内容并且不能解决我的问题"strictNullChecks": true,也没有效果//@ts-ignore线。这有效地消除了错误,并且测试顺利进行虽然我能够进行测试,但我不想在测试中到处都忽略这个错误,并且忽略错误只是一个好主意,直到它不是。
有人对这个问题有更多信息或建议吗?