Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

🔗 Linked issue

Resolves setup-database-for-tests

📚 Description

Replaced vitest-mock-extended with prisma-mock for unit tests to eliminate PostgreSQL dependency and improve test execution speed.

Changes:

  • Prisma schema: Added DMMF generator to export database metadata required by prisma-mock
  • Unit tests: Migrated to prisma-mock with per-test fresh instances and in-test data seeding
    • server/journals/journal.service.spec.ts
    • server/documents/user.document.service.spec.ts
  • Documentation: Added docs/testing-with-prisma-mock.md with implementation guide

Usage pattern:

import createPrismaMock from 'prisma-mock/client'
import { Prisma, type PrismaClient } from '../database'
import * as dmmf from '../database/generated/dmmf'

beforeEach(() => {
  const mockClient = mockDeep<PrismaClient>()
  prisma = createPrismaMock(Prisma, {
    mockClient,
    datamodel: { enums: dmmf.enums, models: dmmf.models }
  })
  // Seed test data
  await prisma.journal.create({ data: testJournal })
})

Integration tests remain on PostgreSQL - they exercise complex nested queries and full-stack behavior that prisma-mock doesn't fully support.

Original prompt

Use https://github.com/demonsters/prisma-mock for setting up the database for unit and integration tests.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Set up database with prisma-mock for tests test: integrate prisma-mock for unit tests Nov 13, 2025
Copilot AI requested a review from tobiasdiez November 13, 2025 13:59
Copilot finished work on behalf of tobiasdiez November 13, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants