I'm trying to mock new Date() to return a specific date. The following code:
const now = new Date()
jest.spyOn(global, 'Date').mockImplementation(() => now)
gives a compilation error: Argument of type '() => Date' is not assignable to parameter of type '() => string'. Type 'Date' is not assignable to type 'string'.
I think the reason is that jest thinks I'm trying to mock Date() instead of new Date(). Indeed, Date() returns a string. How can I solve this issue?