Open kobelobster opened 4 years ago
Hey, for those who end up here by googling, I may have a solution for your issue:
import {Matcher } from "jest-mock-extended";
import { isEqual } from "lodash";
const objectWithTheSameFields = <T>(expectedValue: T) =>
new Matcher<T | unknown>((actualValue) => {
return isEqual(actualValue, expectedValue);
}, "different fields");
// my.test.ts
prismaMock?.someThing?.findMany
.calledWith(
objectWithTheSameFields({
where: {
name: { contains: query },
},
})
)
.mockResolvedValue([{...}]);
I have the following code in my application
where params is something like
When I mock this using the following code
This works without any problems, however, as you can see I also have a callback function as an option. How would I mock that?
Thank you :) Your library helped me so far.