Open smaspe opened 1 year ago
Hey @smaspe, as you can see I have put in a PR for this issue, but I was just wondering if you used a workaround in the meantime?
This is the workaround I am currently using to match my object parameter:
const buildObjectMatcher = (expectedInput) => new Matcher((actual) => JSON.stringify(actual) === JSON.stringify(expectedInput), 'object-matcher')
const myObj = {
myFn: (p1: Object, p2: Primitive) => {} //pseudo-types
};
const expectedInput1 = { an: 'object' };
const expectedInput2 = 'primitive';
myObj.myFn.calledWith(buildObjectMatcher(expectedInput1), expectedInput2).mockResolvedValue(response);
Many functions expect an object as input parameter.
calledWith
relies on strict equality.expect.objectContaining
is a partial match.Is there a way to perform a deep object comparison? Am I missing a built-in matcher, or should I create on myself?
Example: