Skip to content

Commit

Permalink
Add how to mock scoped modules to Manual Mocks doc
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjb committed Feb 22, 2018
1 parent 1203ed6 commit 0beff81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
([#5622](https://github.com/facebook/jest/pull/5622))
* `[docs]` Update to use yarn
([#5624](https://github.com/facebook/jest/pull/5624))
* `[docs]` Add how to mock scoped modules to Manual Mocks doc
([#5638](https://github.com/facebook/jest/pull/5638))

## 22.4.0

Expand Down
6 changes: 6 additions & 0 deletions docs/ManualMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ configured [`roots`](Configuration.md#roots-array-string) to point to a folder
other than the project root) and will be **automatically** mocked. There's no
need to explicitly call `jest.mock('module_name')`.

Scoped modules can be mocked by creating a file in a directory structure that
matches the name of the scoped module. For example, to mock a scoped module
called `@scope/project-name`, create a file at
`__mocks__/@scope/project-name.js`, creating the `@scope/` directory
accordingly.

> Warning: If we want to mock Node's core modules (e.g.: `fs` or `path`), then
> explicitly calling e.g. `jest.mock('path')` is **required**, because core Node
> modules are not mocked by default.
Expand Down

0 comments on commit 0beff81

Please sign in to comment.