Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add how to mock scoped modules to Manual Mocks doc
  • Loading branch information
davidjb committed Feb 22, 2018
commit 0beff814500d2727cc7f18a8b1a53eb0e669dbf7
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