demonsters / prisma-mock

A mock library of Prisma intended for unit testing.
MIT License
115 stars 28 forks source link

Omit on PrismaClient #70

Open mallonenogueira opened 2 months ago

mallonenogueira commented 2 months ago

Hi,

I would like to know if it’s possible to pass the omit attribute to the client.

Here’s my current setup:

// config/prisma
import { PrismaClient } from "@prisma/client";

export const prisma = new PrismaClient({
  log: ['query', 'info', 'warn', 'error'],
  omit: {
    user: {
      password: true,
    },
  },
});
// setup
import { vi } from "vitest";

vi.mock(import("../config/prisma"), async () => {
  const mockImport = await import("../__mock__/prisma.mock");

  return mockImport;
});
///__mock__/prisma.mock"
import { mockDeep } from "vitest-mock-extended";
import createPrismaMock from "prisma-mock";
import { Prisma, PrismaClient } from "@prisma/client";

export const prisma = createPrismaMock<PrismaClient>(
  {},
  Prisma.dmmf.datamodel,
  mockDeep()
);

Let me know if you need anything else!

stijnvanderlaan commented 2 months ago

Hi @mallonenogueira, no this is not yet supported. I'll explore the possibility of adding this feature in the near future.