Mocking dates in jest

Updated February 27, 2023
Created November 21, 2019


new Date(Date.now())

const dateSpy = jest.spy(Date, "now")

Credit to Hugo's post


Comments?