Skip to content

Commit f2acd79

Browse files
waleedlatif1claude
andcommitted
fix(testing): wire dbChainMock.db to shared transaction and execute fns
dbChainMock.db.transaction was an inline vi.fn() separate from the exported dbChainMockFns.transaction, so dbChainMockFns.transaction.mockResolvedValueOnce and assertions silently targeted the wrong instance. dbChainMock.db also omitted execute, so tests for any module that calls db.execute (logging-session, table service, billing balance) would throw TypeError. Both mocks now reference the module-level constants so overrides and resetDbChainMock affect the same fn. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f43fe5a commit f2acd79

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/testing/src/mocks/database.mock.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ export const dbChainMock = {
192192
insert,
193193
update,
194194
delete: del,
195-
transaction: vi.fn(async (cb: (tx: typeof dbChainMock.db) => unknown) => cb(dbChainMock.db)),
195+
execute,
196+
transaction,
196197
},
197198
}
198199

0 commit comments

Comments
 (0)