UNPKG

jest-mock-now

Version:

Date.now() as deterministic Jest mock function.

8 lines (6 loc) 196 B
const { NOW } = require('./constants'); module.exports = date => { const now = date ? date.getTime() : NOW; Date.now = jest.spyOn(Date, 'now').mockImplementation(() => now); return now; };