Quramy / jest-prisma

Jest environment for integrated testing with Prisma client
MIT License
266 stars 15 forks source link

Add option for TransactionIsolationLevel setting #129

Closed danielpowell4 closed 6 months ago

danielpowell4 commented 6 months ago

First up: thanks for this awesome library. It has transformed my day-to-day in a great way!

I'm wondering if you are interested in a pull request to expose 'isloationLevel' as a setting that can be defined for transactions

As context, we're seeing some deadlocks in our growing test suites due to various tests and factories trying to create default users in our test setup. I believe that changing from the postgres default of 'Read Committed' to 'Serializable' would help us

As of a few days ago, Prisma itself merged a PR to allow these transaction options to be set on the PrismaClient via a new transactionOptions setting per https://github.com/prisma/prisma/pull/19592

I believe it would most need to be added here with a safe default of 'undefined'

https://github.com/Quramy/jest-prisma/blob/8daaa44417f92c635663e3a5d28c571d6cf7af17/packages/jest-prisma-core/src/delegate.ts#L127-L130

More reading: https://www.prisma.io/docs/orm/prisma-client/queries/transactions#transaction-isolation-level

Prisma support + database defaults: https://www.prisma.io/docs/orm/prisma-client/queries/transactions#supported-isolation-levels

Quramy commented 6 months ago

Closed via #132