jest-prisma
jest-prisma copied to clipboard
Unable to Use jestPrisma as a Global Object in Test Environment with Blitz.js
Description
I tried to set up the jest-prisma environment with a Blitz.js app, following the documentation, but encountered an issue where jestPrisma is not defined in the test environment.
Code and Configuration
jest.config.js
module.exports = {
preset: "blitz",
testEnvironment: "@quramy/jest-prisma/environment",
}
tsconfig.js
"compilerOptions": {
// other configurations
"types": ["@types/jest", "@quramy/jest-prisma"]
}
the test I wrote
describe("jest-prisma test",()=>{
it("should be able to use jest-prisma",async()=>{
const data = {
name:"test venue",
email: '[email protected]'
}
await jestPrisma.client.user.create({
data,
})
const result = await jestPrisma.client.user.findMany()
expect(result).toEqual([data])
})
})
Expected Behavior
jestPrisma should be provided as a global object and the test should run without issues.
Actual Behavior
I encountered a ReferenceError when running the test:
ReferenceError: jestPrisma is not defined
Version Info
@prisma/client: 3.9.2 (Using previewFeatures: ["interactiveTransactions", "referentialActions"]) blitz: 0.44.3 Node.js: 14.21.3 OS: Mac 12.6