There are situations where Date.now is used in application code. That code needs to be tested, and it’s always a struggle to remember how to mock D...
For further actions, you may consider blocking this person and/or reporting abuse
You might run the risk of tests after this one failing if there is an exception in this test that prevents Date.now being set back.
Using beforeEach and after each could help with Code reuse and this possible scenario.
Wrap in try, finally. Alternatively create a utility function to create now date, and mock that
Also great for mocking Math.random I imagine.
How can you mock date constructor?
So imagine date is created with "const now = new Date()".
I would like to have "now" to have specific mocked date.
global.Date = myMockConstructor