Skip to content Skip to sidebar Skip to footer

Spying On Date Constructor With Sinon

I have a method that sets expiration date of a token: var jwt = require('jwt-simple'); module.exports = { setExpirationDate: function(numDays) { var dateObj = new Dat

Solution 1:

Considering your constructor is bound to 'global' which means that if you open developer console on your browser, you should be able to intantiate an object by using the related function/constructor as such:

varDate = newDate();

If so actual working code could be:

varDate = sinon.spy(global, 'Date');

expect(Date.called).to.be.equal(true);

Post a Comment for "Spying On Date Constructor With Sinon"