Skip to content

Commit

Permalink
Expose restoreAllMocks to object (jestjs#4463)
Browse files Browse the repository at this point in the history
  • Loading branch information
thymikee authored and tabrindle committed Oct 2, 2017
1 parent 5681788 commit 88c4f01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,10 @@ class Runtime {
this.resetAllMocks();
return jestObject;
};
const restoreAllMocks = () => {
this.restoreAllMocks();
return jestObject;
};
const useFakeTimers = () => {
this._environment.fakeTimers.useFakeTimers();
return jestObject;
Expand Down Expand Up @@ -743,7 +747,6 @@ class Runtime {
const jestObject = {
addMatchers: (matchers: Object) =>
this._environment.global.jasmine.addMatchers(matchers),

autoMockOff: disableAutomock,
autoMockOn: enableAutomock,
clearAllMocks,
Expand All @@ -759,29 +762,25 @@ class Runtime {
this._generateMock(from, moduleName),
genMockFunction: fn,
isMockFunction: this._moduleMocker.isMockFunction,

mock,
requireActual: localRequire.requireActual,
requireMock: localRequire.requireMock,
resetAllMocks,
resetModuleRegistry: resetModules,
resetModules,

restoreAllMocks,
runAllImmediates: () => this._environment.fakeTimers.runAllImmediates(),
runAllTicks: () => this._environment.fakeTimers.runAllTicks(),
runAllTimers: () => this._environment.fakeTimers.runAllTimers(),
runOnlyPendingTimers: () =>
this._environment.fakeTimers.runOnlyPendingTimers(),
runTimersToTime: (msToRun: number) =>
this._environment.fakeTimers.runTimersToTime(msToRun),

setMock: (moduleName: string, mock: Object) =>
setMockFactory(moduleName, () => mock),
setTimeout,
spyOn,

unmock,

useFakeTimers,
useRealTimers,
};
Expand Down
1 change: 1 addition & 0 deletions types/Jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type Jest = {|
resetAllMocks(): Jest,
resetModuleRegistry(): Jest,
resetModules(): Jest,
restoreAllMocks(): Jest,
runAllImmediates(): void,
runAllTicks(): void,
runAllTimers(): void,
Expand Down

0 comments on commit 88c4f01

Please sign in to comment.