Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save josbelvivial/02416012d0a90f07937efb60b38dc066 to your computer and use it in GitHub Desktop.
Save josbelvivial/02416012d0a90f07937efb60b38dc066 to your computer and use it in GitHub Desktop.
Fake a date in node.js for testing with sinon
clock = sinon.useFakeTimers(new Date(2016,11,1).getTime());
new Date(); //=> return the fake Date 'Sat Nov 01 2016 00:00:00'
clock.restore();
new Date(); //=> will return the real time again (now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment