import { spy } from 'sinon'; const myFunction = spy(); myFunction('hello'); myFunction('world'); console.log(myFunction.called); //True console.log(myFunction.calledOnce); //False console.log(myFunction.calledTwice); //True console.log(myFunction.calledWith('hello')); //True console.log(myFunction.calledWith('goodbye')); //FalseIn this example, we create a spy function called 'myFunction'. We then call the function twice with different arguments. Finally, we use some of the SinonSpy methods to check whether the function has been called as expected. Package library: sinon.