Reputation: 99
stub.yield([arg1, arg2, ...])
Invoke callbacks passed to the
stub
with the given arguments. If the stub was never called with a function argument,yield
throws an error. Also aliased asinvokeCallback
.
What does it mean "If the stub was never called with a function argument" ?
Upvotes: 1
Views: 1429
Reputation: 1622
It means that if the stub was called, but there was no function in the given arguments, an exception is thrown.
Consider this stub:
sinon.stub(fs, 'readFile');
Now the test runs these lines:
fs.readFile('some-file'); // no callback passed
fs.readFile.yield(); // throws, because the stub was never invoked with a function
Upvotes: 1