Skip to content

Instantly share code, notes, and snippets.

@dylansmith
Created April 3, 2018 15:03
Show Gist options
  • Save dylansmith/cfec3d821ae9e7dbf6c4907484f5aa8d to your computer and use it in GitHub Desktop.
Save dylansmith/cfec3d821ae9e7dbf6c4907484f5aa8d to your computer and use it in GitHub Desktop.
Native JS datetime mocking
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