jest.mock('randomstring', () => ({ generate: jest.fn(() => 'mocked-random-string'), })); beforeEach(() => { jest.spyOn(Date, 'now').mockImplementation(() => 639837296000); });