To set a mock date in Jest and JavaScript, we can use the useFakeTimers and setSystemTime methods.
For instance, we write:
jest
.useFakeTimers()
.setSystemTime(new Date('2022-01-01').getTime());
to call useFakeTimers to let us mock timers.
Then we call setSystemTime to set the time of the mock timer by calling it with a timestamp in milliseconds.