Mocking dates in jest

Updated May 26, 2024
Created November 21, 2019


new Date(Date.now())

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

Credit to Hugo's post


Comments?