-
-
Save josbelvivial/ef9719eac6e038f0946965c19baaba23 to your computer and use it in GitHub Desktop.
Fake a date in node.js for testing with sinon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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