From d8a8931bc32170063634d015b0e0927600b36f51 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 1 Apr 2026 14:06:57 -0700 Subject: [PATCH] fix(tests): add @prisma/client mock for test isolation Mock @prisma/client globally in bun-setup.ts to allow unit tests to run without requiring the generated Prisma client. This improves test isolation and allows tests to pass even when prisma generate hasn't been run. --- src/__tests__/bun-setup.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/__tests__/bun-setup.ts b/src/__tests__/bun-setup.ts index 8a979df..b3444cf 100644 --- a/src/__tests__/bun-setup.ts +++ b/src/__tests__/bun-setup.ts @@ -1,8 +1,21 @@ // Setup file for Bun test runner to provide DOM environment import { JSDOM } from 'jsdom'; +import { mock } from 'bun:test'; console.log('Loading bun-setup.ts...'); +// Mock @prisma/client to avoid dependency on generated Prisma client +// This allows unit tests to run without requiring `prisma generate` +mock.module('@prisma/client', () => { + return { + PrismaClient: class MockPrismaClient { + $connect() {} + $disconnect() {} + $transaction() {} + } + }; +}); + const dom = new JSDOM('', { url: 'http://localhost', pretendToBeVisual: true,