morintd / prismock

A mock for PrismaClient, dedicated to unit testing.
https://www.npmjs.com/package/prismock
MIT License
203 stars 23 forks source link

Support for _count for related records #1106

Open thw0rted opened 1 month ago

thw0rted commented 1 month ago

Using Prismock 1.33.1. Our code under test looks like

prisma.user.findMany({
  include: {
    post: {
      orderBy: { date: 'desc' },
      select: { id: true, name: true },
      take: 5
    },
    _count: {
      select: { post: true },
    }
  }
})

The idea being to get the name and ID of the most recent 5 posts by each user, along with a count of all their posts. Prismock seems to be ignoring the _count option. When running tests, no _count is present on the results.

I think this might be what the README means when it says that "select + count" is unsupported. If that's the case, what would it take to add support?