Skip to content

Instantly share code, notes, and snippets.

@sungchuni
Last active January 21, 2021 05:16
Show Gist options
  • Save sungchuni/2c360af1c152a0e45eda8aeac6fc5527 to your computer and use it in GitHub Desktop.
Save sungchuni/2c360af1c152a0e45eda8aeac6fc5527 to your computer and use it in GitHub Desktop.
function setMockDate() {
class MockedDate extends Date {
constructor(...args) {
const [firstArg, ...restArgs] = args;
firstArg === undefined
? super("2020-09-01T12:00:00.000+09:00", ...restArgs)
: super(...args);
}
}
const {Date: ProperDate} = globalThis;
globalThis.Date = MockedDate;
return ProperDate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment