Skip to content

Programmatically reproduce your own Groundhog Day. (Mocks JS Date)

License

Notifications You must be signed in to change notification settings

kevincharm/chronomancer

Repository files navigation

chronomancer

Manipulates the global Date object; useful for tests.

Installation

Get it via npm:

npm install --save chronomancer

Usage

import { freezeDate, resetDate } from 'chronomancer'

freezeDate('2017-01-31')        // Accepts whatever the Date() constructor can parse

const frozen = 1517356800000    // => 2018-01-31 in UNIX epoch time
assert(Date.now(), frozen)
assert(Date.now(), frozen)

resetDate()                     // Resets the global Date object
assert(Date.now(), frozen)      // This will throw AssertionError (unless you've figured out time travel)

About

Programmatically reproduce your own Groundhog Day. (Mocks JS Date)

Resources

License

Stars

Watchers

Forks

Packages

No packages published