diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts index 42cb7f8927c1..b5920f7d00e9 100644 --- a/packages/jest-environment/src/index.ts +++ b/packages/jest-environment/src/index.ts @@ -10,6 +10,7 @@ import type {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers'; import type {Circus, Config, Global} from '@jest/types'; import type { fn as JestMockFn, + mocked as JestMockMocked, spyOn as JestMockSpyOn, ModuleMocker, } from 'jest-mock'; @@ -191,6 +192,7 @@ export interface Jest { * jest.spyOn; other mocks will require you to manually restore them. */ restoreAllMocks(): Jest; + mocked: typeof JestMockMocked; /** * Runs failed tests n-times until they pass or until the max number of * retries is exhausted. This only works with `jest-circus`! diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 8640b45ea405..2746f303b1f8 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -1924,6 +1924,7 @@ export default class Runtime { }; const fn = this._moduleMocker.fn.bind(this._moduleMocker); const spyOn = this._moduleMocker.spyOn.bind(this._moduleMocker); + const mocked = this._moduleMocker.mocked.bind(this._moduleMocker); const setTimeout = (timeout: number) => { if (this._environment.global.jasmine) { @@ -1975,6 +1976,7 @@ export default class Runtime { isMockFunction: this._moduleMocker.isMockFunction, isolateModules, mock, + mocked, requireActual: this.requireActual.bind(this, from), requireMock: this.requireMock.bind(this, from), resetAllMocks,