3 ms·
If I have an operation that is dependent on "now", I typically generate that time at the beginning of the operation and pass it as a parameter to everything els
by jdmichal 11y ago
If I have an operation that is dependent on "now", I typically generate that time at the beginning of the operation and pass it as a parameter to everything else. So now all the important bits I can test with whatever timestamp I want. And if I really want to, I could test that the operation initialization generates the correct timestamp. But that's pretty close to testing whether "new Date()" works, which if it doesn't there's not a whole lot I can do about it anyway.