docs/concepts/assertions/api/called-with-match.md
assert.calledWithMatch(spyOrSpyCall, arg1, arg2, ...)Passes, when the fake, spy or stub was called with matching arguments.
This behaves the same way as sinon.assert.calledWith(spy, sinon.match(arg1), sinon.match(arg2), ...).
It's possible to assert on a dedicated spyCall: sinon.assert.calledWithMatch(spy.secondCall, arg1, arg2, ...);.
import * as sinon from "sinon";
const fake = sinon.fake();
const applePieExpectation = {
name: "apple pie"
};
const cherryPieExpectation = {
name: "cherry pie"
};
fake({
name: "apple pie",
price: 123
});
// Matches, generates no error
sinon.assert.calledWithMatch(fake, applePieExpectation);
// Does not match
sinon.assert.calledWithMatch(fake, cherryPieExpectation);
// => Uncaught Error [AssertError]: expected fake to be called with match
// => { name: 'apple pie', price: 123 } { name: 'cherry pie' }
spyCallimport * as sinon from "sinon";
const fake = sinon.fake();
const applePieExpectation = {
name: "apple pie"
};
const cherryPieExpectation = {
name: "cherry pie"
};
fake({
name: "apple pie",
price: 123
});
// get a spyCall instance
const call = fake.firstCall;
// Matches, generates no error
sinon.assert.calledWithMatch(call, applePieExpectation);
<<< ../../../.vitepress/tests/docs/assertions/api/called-with-match.test.js