I've an app that changes it's behaviour with the date. On my mock tests I need to override the new Date()
function to test all the scenarios. Does anyone know how to override it?
I already tried to use the executeScript to change the return value but it doesn't work.
browser.driver.executeScript('' +
'Date = function(){return new Date(2012, 0, 20)};'
);
The replacement function depends on the original Date that's been replaced, so keep a reference to it in a closure, e.g.: