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

[Documentation] Improve automock/add note to automock #8049

Closed
michaelw85 opened this issue Mar 5, 2019 · 3 comments · Fixed by #8051
Closed

[Documentation] Improve automock/add note to automock #8049

michaelw85 opened this issue Mar 5, 2019 · 3 comments · Fixed by #8051

Comments

@michaelw85
Copy link
Contributor

Automock's default value is false, which gave me the expectation nothing is mocked at all.

For my project I started adding mocks at root level and manually calling jest.mock('a_node_module') which worked fine at first until I had a test where I did not explicitly called jest.mock but still ended up with a mocked version.
It took me a while to find this documentation

If the module you are mocking is a Node module (e.g.: lodash), the mock should be placed in the mocks directory adjacent to node_modules (unless you configured roots 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').

It would be nice to add a reference to this piece of documentation or add an additional "note" to automock.

@SimenB
Copy link
Member

SimenB commented Mar 5, 2019

Wanna send a PR for that? :)

michaelw85 added a commit to michaelw85/jest that referenced this issue Mar 5, 2019
Add info related to manual mocks for node module mocks.

Closes jestjs#8049
@michaelw85
Copy link
Contributor Author

@SimenB Create (my first jest 🎉) PR to improve docs.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants