You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Jest and jest-mock-extended to do unit testing on some more complex functions in my code. However I ran into an issue where I need to get nested data or something from prisma. and I can't see anything on Prisma's official website about this and couldn't see anything, I also had a read through this article
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Question
I'm using Jest and jest-mock-extended to do unit testing on some more complex functions in my code. However I ran into an issue where I need to get nested data or something from prisma. and I can't see anything on Prisma's official website about this and couldn't see anything, I also had a read through this article
For example:
When I just run this code:
Jest works great and gets the mocked data, but when I add the .posts() I get an error saying TypeError: person.posts is not a function.
I do my mocked person data like so:
I understand why this error occurs, but I can't work out the syntax to get the mocked posts in there as everything I try throws a TS error.
Things I tried (assume data between the []):
How to reproduce (optional)
Expected behavior (optional)
No response
Information about Prisma Schema, Client Queries and Environment (optional)
No response
Beta Was this translation helpful? Give feedback.
All reactions