set-now
Adds Date.setNow()
to JavaScript's global Date
object.
This is useful for making tests deterministic. Wind back the clock to a time in the past (or in the future).
Install
npm install set-now
Usage
Date // Thu Mar 17 2016 08:00:00 GMT-0400 (EDT)Date // 1458216000000 // wait 1 second
Date.setNow( [time] )
Set the clock to the specified time.
time
{String} (optional) The time you want it to be. Iftime
is not specified, the clock will be reset to the actual time.