Created
April 3, 2018 15:03
-
-
Save dylansmith/cfec3d821ae9e7dbf6c4907484f5aa8d to your computer and use it in GitHub Desktop.
Native JS datetime mocking
This file contains hidden or 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
function mockTime(val) { | |
Date = new Proxy(Date, { | |
construct: function(target, args) { | |
if (args.length === 0) { | |
return new target(val); | |
} | |
return new target(...args); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment