Here is the code I am currently testing:
obj.getTimeSent().getTime();
In this snippet, obj.getTimeSent()
returns a Date object, followed by calling the getTime()
method on that Date.
My attempt to stub this functionality looked like this:
const timeStub = sandbox.stub(Obj, 'getTimeSent').callsFake(() => {
return 1 //The returned value doesn't matter in this case
});
The error message "TypeError: obj.getTimeSent(...).getTime is not a function" was encountered even though according to the sinon documentation, the callsFake()
function should "Make the stub call the provided fakeFunction when invoked".