Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add how to mock scoped modules to Manual Mocks doc #5638

Merged
merged 1 commit into from
Feb 22, 2018
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
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