jeudi 12 juillet 2018

stubbing process.nextTick to relay arguments

For better or worse we stub process.nextTick to call its first argument (the callback) synchronously. Behold the code:

global.test_clock = sinon.useFakeTimers();
sinon.stub(process, 'nextTick').callsArg(0);

However process.nextTick takes a function and an arbitrary set of arguments to pass to that function. The above code drops those extra arguments.

Can a Sinon sage advise how I can call arg 0 (the callback) with the remaining arguments as arguments to the callback?

Aucun commentaire:

Enregistrer un commentaire