const sinon = require('sinon'); // Create a spy const myFunc = sinon.spy(); // Call myFunc with some arguments myFunc({ name: 'John', age: 30 }); // Assert that myFunc was called with an object that matches a pattern sinon.assert.calledWithMatch(myFunc, { name: sinon.match.string, age: sinon.match.number });
const sinon = require('sinon'); // Create a spy const myFunc = sinon.spy(); // Call myFunc with some arguments myFunc(10, 'hello'); // Assert that myFunc was called with arguments that match a pattern sinon.assert.calledWithMatch(myFunc, sinon.match.number, sinon.match.string);In this example, we create a spy called `myFunc` and call it with two arguments: a number and a string. We then use `sinon.assert.calledWithMatch` to ensure that `myFunc` was called with a number and a string. The `calledWithMatch` assertion is a part of the Sinon library.