DEV Community

Discussion on: Mocking JavaScript's current Date in Jest tests

Collapse
 
borys_kupar profile image
Borys Kupar

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.

Collapse
 
hugo__df profile image
Hugo Di Francesco

global.Date = myMockConstructor