First, thanks for this amazing library!
I have being facing some issues when testing APIs that receive objects as arguments. Seems like the received call checks does not deep compare objects. Check out the example bellow:
it("it should get the correct object", async () => {
const obj = {
action: (value: { prop: string }) => `wow ${value.prop}`
};
const objMock = Substitute.for<typeof obj>();
const arg = { prop: "wow" };
objMock.action(arg);
// This test passes
objMock.received().action(arg);
/* This fails with:
Expected 1 or more calls to the method action2 with arguments [{ prop: 'wow' }], but received none of such calls.
All calls received to method action2:
-> call with arguments [{ prop: 'wow' }]
*/
objMock.received().action({ prop: "wow" });
});
I believe a possible solutions would be the library to offer a way to deep-compare the arguments. Another solution would be a method to have access to the list of calls and arguments, so we can compare the arguments using for example Jest expect.
I am open for thoughts and suggestions.
First, thanks for this amazing library!
I have being facing some issues when testing APIs that receive objects as arguments. Seems like the received call checks does not deep compare objects. Check out the example bellow:
I believe a possible solutions would be the library to offer a way to deep-compare the arguments. Another solution would be a method to have access to the list of calls and arguments, so we can compare the arguments using for example Jest expect.
I am open for thoughts and suggestions.