P
Prisma4mo ago
jay !!

unit testing with @default() value, using jest-mock-extended

Hello :) I'm not sure this is the appropriate place to post this, but I hope I can get some help here. I'm currently working on a project and was looking into unit testing my prisma extended client with unit tests and jest.
8 Replies
jay !!
jay !!OP4mo ago
I read this guide
Unit testing with Prisma ORM | Prisma Documentation
Learn how to setup and run unit tests with Prisma Client
jay !!
jay !!OP4mo ago
No description
jay !!
jay !!OP4mo ago
The issue is the mockResolvedValue function expects my user object to have an ID, as specified in the model. I don't believe I should have to include an ID here, as it will be generated by Prisma. is there any way around this? upon supplying an id, it still errors but the expected object isn't the one i need - i want it to generate the id and return that object, am i thinking about this wrong?
jay !!
jay !!OP4mo ago
No description
jay !!
jay !!OP4mo ago
update: i'm now getting this error, not a clue why or how to fix
jay !!
jay !!OP4mo ago
No description
jay !!
jay !!OP4mo ago
No description
jay !!
jay !!OP4mo ago
on line 10

Did you find this page helpful?