Skip to content

Latest commit

 

History

History
31 lines (18 loc) · 917 Bytes

File metadata and controls

31 lines (18 loc) · 917 Bytes

elections-cpl.api.hscc.bdpa.orgDocs


elections-cpl.api.hscc.bdpa.org / lib/jest-mock-date / useMockDateNow

Function: useMockDateNow()

useMockDateNow(options?): void

Sets up a Jest spy on the Date object's now method such that it returns mockNow or mockDateNowMs (default) rather than the actual date. If you want to restore the mock, you will have to do so manually (or use Jest configuration to do so automatically).

This is useful when testing against/playing with dummy data containing values derived from the current time (i.e. unix epoch).

Parameters

options?

options.mockNow?: number

Returns

void

Source

lib/jest-mock-date/index.ts:15