Instead of calling Date.now() or opening a database connection itself, the function takes it as a parameter. A test passes a fake one and gets a deterministic result.