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'd like to have the unit testing of code working with prisma be more precise about what is being passed into and returned from the mocked prisma method. The examples in the documentation make use of mockResolvedValue (with the same data passed into the tested object as is returned by the prisma method) but I'd like to use mockImplementation so I can ensure the prisma method is working with the data that was actually supplied to it.
Suggested solution
Allow (or document if it is already possible) alternative mocking techniques.
Additional context
The suggested mocking solution
test('should create new user ',async()=>{constuser={id: 1,name: 'Rich',email: '[email protected]',acceptTermsAndConditions: true,}prismaMock.user.create.mockResolvedValue(user)awaitexpect(createUser(user)).resolves.toEqual({id: 1,name: 'Rich',email: '[email protected]',})})
would still pass even if the implementation of createUser was:
I would love to see it too, because right now unit testing is really difficult to achieve with more complex problems. Right now there are really simple use-cases possible with unit tests.
Problem
I'd like to have the unit testing of code working with prisma be more precise about what is being passed into and returned from the mocked prisma method. The examples in the documentation make use of
mockResolvedValue
(with the same data passed into the tested object as is returned by the prisma method) but I'd like to usemockImplementation
so I can ensure the prisma method is working with the data that was actually supplied to it.Suggested solution
Allow (or document if it is already possible) alternative mocking techniques.
Additional context
The suggested mocking solution
would still pass even if the implementation of
createUser
was:i.e. the failure by the function to pass the email value down to prisma is not shown by the test.
I've tried using
create.mockImplementation
but get the equivalent ofThe text was updated successfully, but these errors were encountered: