prisma-appsync icon indicating copy to clipboard operation
prisma-appsync copied to clipboard

Impossible to perform integration tests because of JEST_WORKER_ID conditions

Open Loupi opened this issue 3 years ago • 1 comments

Hello,

Thank you for this library, it saves a lot of time. I'm currently experimenting it with a custom prisma middleware and prisma casl. The middleware adds additional conditions in where clauses on hierarchical queries, and also performs some input validation for connect, create and createOrConnect. I also developed a graphql to appsync event converter to ease the process.

I was trying to run some integration tests with Jest, but the prisma-appsync code has conditions like this before prisma calls: if (process.env.JEST_WORKER_ID) return args

This is great for unit tests, but it makes it impossible to perform integration tests that need to query the database.

Maybe using a custom environment variable instead of JEST_WORKER_ID would help here.

Current workaround is to reset the JEST_WORKER_ID in beforeEach, but it makes me feel uncomfortable.

beforeEach(() => {
  if (process.env.JEST_WORKER_ID) {
    process.env.JEST_WORKER_ID = ''
  }
})

Regards

Loupi avatar Nov 18 '21 17:11 Loupi

That's a good point indeed. I've added your request to the roadmap for next release!

maoosi avatar Nov 19 '21 09:11 maoosi