diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 3c9eb27d93..d2b1865a6f 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -60,6 +60,12 @@ declare namespace jest { * Equivalent to calling .mockClear() on every mocked function. */ function resetAllMocks(): typeof jest; + /** + * available in Jest 20.1.0+ + * Restores all mocks back to their original value. Equivalent to calling .mockRestore on every mocked function. + * Beware that jest.restoreAllMocks() only works when mock was created with jest.spyOn; other mocks will require you to manually restore them. + */ + function restoreAllMocks(): typeof jest; /** * Removes any pending timers from the timer system. If any timers have * been scheduled, they will be cleared and will never have the opportunity diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index ff01b154ad..b3d34b200b 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -17,6 +17,12 @@ describe('sum', () => { }); }); +describe('restoreAllMocks', () => { + afterEach(() => { + jest.restoreAllMocks(); + }); +}); + describe('fetchCurrentUser', () => { it('calls the callback when $.ajax requests are finished', () => { const fetchCurrentUser = require('../fetchCurrentUser');