Pieces are a noop function with programmable behavior. In your case, it will callsArg(index)program the stub to wait for function in indexand immediately call it.
function sayHi() {
console.log('hi');
}
var stub = sinon.stub().callsArg(2);
stub('abc', 42, sayHi);