Skip to content

Instantly share code, notes, and snippets.

@marquesm91
Created October 30, 2019 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marquesm91/070979b0770bfb29b4831a115fa04290 to your computer and use it in GitHub Desktop.
Save marquesm91/070979b0770bfb29b4831a115fa04290 to your computer and use it in GitHub Desktop.
Date Mock
// https://github.com/facebook/jest/issues/2234#issuecomment-397321562
let currentDate;
beforeAll(() => {
currentDate = new Date();
const RealDate = Date;
global.Date = jest.fn(() => new RealDate(currentDate.toISOString()));
Object.assign(Date, RealDate);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment