Skip to content

Commit

Permalink
Update /jest-environment/src/index.ts - Add example to requireActual
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandrina Pereira committed May 22, 2019
1 parent 0e7f2fe commit 4e3585f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/jest-environment/src/index.ts
Expand Up @@ -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;
/**
Expand Down

0 comments on commit 4e3585f

Please sign in to comment.