Skip to content

Commit 2dabd5c

Browse files
authored
[jest-environment] adding mocked in jest object (#12133)
1 parent 5ccb0a0 commit 2dabd5c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

packages/jest-environment/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers';
1010
import type {Circus, Config, Global} from '@jest/types';
1111
import type {
1212
fn as JestMockFn,
13+
mocked as JestMockMocked,
1314
spyOn as JestMockSpyOn,
1415
ModuleMocker,
1516
} from 'jest-mock';
@@ -191,6 +192,7 @@ export interface Jest {
191192
* jest.spyOn; other mocks will require you to manually restore them.
192193
*/
193194
restoreAllMocks(): Jest;
195+
mocked: typeof JestMockMocked;
194196
/**
195197
* Runs failed tests n-times until they pass or until the max number of
196198
* retries is exhausted. This only works with `jest-circus`!

packages/jest-runtime/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,7 @@ export default class Runtime {
19241924
};
19251925
const fn = this._moduleMocker.fn.bind(this._moduleMocker);
19261926
const spyOn = this._moduleMocker.spyOn.bind(this._moduleMocker);
1927+
const mocked = this._moduleMocker.mocked.bind(this._moduleMocker);
19271928

19281929
const setTimeout = (timeout: number) => {
19291930
if (this._environment.global.jasmine) {
@@ -1975,6 +1976,7 @@ export default class Runtime {
19751976
isMockFunction: this._moduleMocker.isMockFunction,
19761977
isolateModules,
19771978
mock,
1979+
mocked,
19781980
requireActual: this.requireActual.bind(this, from),
19791981
requireMock: this.requireMock.bind(this, from),
19801982
resetAllMocks,

0 commit comments

Comments
 (0)