How to mock new Date()
without arguments with jest?
I looked at the accepted answer on stackoverflow
const mockDate = new Date(..);
const spy = jest
.spyOn(global, 'Date')
.mockImplementation(() => mockDate)
What I expected is when jest runs the code: new Date()
to use the mock. but when it run new Date(.....)
to ignore the mock.
How to do it with jest? is it possible anyway?