DEV Community

Feralamillo
Feralamillo

Posted on

1

Mocking date.now() with jest.

Mocking Date.now() in a jest unit test.

jest
 .spyOn(global.Date, 'now')
 .mockImplementationOnce(() =>
    new Date('2010-10-10T10:10:10.100Z').valueOf()
  );

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More