I\'m testing a function that takes a date as an optional argument. I want to assert that a new Date object is created if the function is called without the argument.
this worked for me
var baseTime = new Date().getTime(); spyOn(window, 'Date').and.callFake(function() { return {getTime: function(){ return baseTime;}}; });