MCPcopy
hub / github.com/prisma/prisma / deferredTransaction

Function deferredTransaction

packages/adapter-planetscale/src/planetscale.test.ts:32–41  ·  view source on GitHub ↗
(afterCallback?: () => never | void)

Source from the content-addressed store, hash-verified

30 // one microtask (via internal async operations like BEGIN). We simulate this with
31 // `await Promise.resolve()` to avoid the `txResultPromise` temporal dead zone.
32 function deferredTransaction(afterCallback?: () => never | void) {
33 return vi.fn((fn: (tx: any) => Promise<void>) => {
34 const mockTx = { execute: vi.fn() }
35 return Promise.resolve()
36 .then(() => fn(mockTx))
37 .then(() => {
38 afterCallback?.()
39 })
40 })
41 }
42
43 test('commit succeeds when conn.transaction() resolves', async () => {
44 const adapter = createAdapterWithMockConnection(deferredTransaction())

Callers 1

Calls 2

thenMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected