I want to be able to mock the current date/time used by new Date()
or in any other built-in date function in JS. This is so I can test our application in exactly the same state every time (since a lot of things change depending on the current date).
I would like to be able to change this in a single place so I don’t have to go through the entire codebase and make a mess. To my surprise I couldn’t find any such function for JS, even though this is a basic feature of any programming language.
Note that I want to do this with plain JS. I’m not using any sort of testing framework like Jest.