'mockRestore does not clear a jest.spyOn().mockImplementation mock

I am mocking Date.now() implementation returning a specific date however, after the test is done the afterAll + mockRestore() doesn't quite rid of the mock.

When I run another test the date now is still mocked to 1626764400000. Is there a different function I have to use to reset the mock? I have already used: mockReset, mockClear, jest.clearAllMocks.

beforeAll((): void => {
  jest.spyOn(Date, 'now').mockImplementation(() => 1626764400000);
});

afterAll((): void => {
  jest.clearAllMocks();
  jest.spyOn(Date, 'now').mockRestore();
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source