Skip to content

Commit

Permalink
Update JestObjectAPI on versioned docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandrina Pereira committed May 22, 2019
1 parent 2d2db86 commit 0e7f2fe
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
19 changes: 19 additions & 0 deletions website/versioned_docs/version-22.x/JestObjectAPI.md
Expand Up @@ -444,6 +444,25 @@ This is useful for scenarios such as one where the module being tested schedules

Returns the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not.

Example:

```js
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;

getRandom(); // Always returns 10
```

### `jest.requireMock(moduleName)`

Returns a mock module instead of the actual module, bypassing all checks on whether the module should be required normally or not.
Expand Down
19 changes: 19 additions & 0 deletions website/versioned_docs/version-23.x/JestObjectAPI.md
Expand Up @@ -460,6 +460,25 @@ This is useful for scenarios such as one where the module being tested schedules

Returns the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not.

Example:

```js
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;

getRandom(); // Always returns 10
```

### `jest.requireMock(moduleName)`

Returns a mock module instead of the actual module, bypassing all checks on whether the module should be required normally or not.
Expand Down
19 changes: 19 additions & 0 deletions website/versioned_docs/version-24.0/JestObjectAPI.md
Expand Up @@ -322,6 +322,25 @@ _Note It is recommended to use [`jest.mock()`](#jestmockmodulename-factory-optio

Returns the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not.

Example:

```js
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;

getRandom(); // Always returns 10
```

### `jest.requireMock(moduleName)`

Returns a mock module instead of the actual module, bypassing all checks on whether the module should be required normally or not.
Expand Down

0 comments on commit 0e7f2fe

Please sign in to comment.