Tip: Mocking JavaScript Date Class with Jest
Takahiro Iwasa
1 min read
Jest
I was looking for a technique to mock new Date()
with Jest.
Developers can use fake timers and setSystemTime
like the following.
jest
.useFakeTimers()
.setSystemTime(new Date('2023-01-02 12:34:56'));