Skip to content

Commit

Permalink
[jest-environment] adding mocked in jest object (#12133)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-rajat19 committed Dec 10, 2021
1 parent 5ccb0a0 commit 2dabd5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/jest-environment/src/index.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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`!
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-runtime/src/index.ts
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2dabd5c

Please sign in to comment.