I need to check a URL that was passed to a method. I wrote a custom matcher for this but I don't know how to use it in toHaveBeenCalledWith
.
How can I use my custom matcher in this situation?
E.g. in C# Moq I can do the following to match only even numbers:
mock.Setup(foo => foo.Add(It.Is<int>(i => i % 2 == 0))).Returns(true);
Maybe not as elegant as what you're looking for, but you should be able to apply your custom matcher to
yourMockFunction.mock.calls[0][0]
.If there are multiple arguments, you can read the next elements in
mockFunction.mock.calls[0]
. If you want to check multiple calls, they will be available inmockFunction.mock.calls[1]
,mockFunction.mock.calls[2]
and so on.