diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts index eb54bade0963..7e228ba1a673 100644 --- a/packages/jest-environment/src/index.ts +++ b/packages/jest-environment/src/index.ts @@ -137,6 +137,19 @@ export interface Jest { /** * Returns the actual module instead of a mock, bypassing all checks on * whether the module should receive a mock implementation or not. + * + * @example + jest.mock('../myModule', () => { + // Require the original module to not be mocked... + const originalModule = jest.requireActual(moduleName); + return { + __esModule: true, // Use it when dealing with esModules + ...originalModule, + getRandom: jest.fn().mockReturnValue(10), + }; + }); + + const getRandom = require('../myModule').getRandom; */ requireActual: (moduleName: string) => unknown; /**