Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Use jestPrisma as a Global Object in Test Environment with Blitz.js #106

Open
yharima opened this issue Oct 15, 2023 · 0 comments

Comments

@yharima
Copy link

yharima commented Oct 15, 2023

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: '1@example.com'
      }
    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant