Problems with "Manual Mocks" docs page
See original GitHub issueThe Manual Mocks docs page has a few problems.
- Although it clearly explains the directory structure for how to add a mock version of one of your own modules (e.g.
models/user.js
andmodels/__mocks__/user.js
), it does not give any example of what that mock file’s contents should look like.- Needs an example on how to mock your own CommonJS module. I’m guessing this will look similar to the example for mocking a built-in module, but not sure.
- Also needs an example on how to mock your own ES6 module with default exports and named exports. Does this look different from mocking a CommonJS module? Do you need to mock the default export like
module.exports.default = ...
, or can you useexport default ...
? An example showing the canonical, recommended approach is needed.
- The section “Using with ES module imports” links off to this repo to explain how things work with ES6
import
/export
statements. But that repo does not contain a single example of animport
/export
statement, so it’s unclear what the reader is supposed to be looking for.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Manual Mocks - Jest
One downside to fully manual mocks is that they're manual – meaning you have to manually update them any time the module they...
Read more >Manual mocking using __mocks__ not working - Stack Overflow
I went through jest documentation for manual mocking and tried creating mocks folder as instructed. Please find the folder structure below. app ...
Read more >"Manual Mocks" docs page does not address manual ... - GitHub
Bug Report When using named imports the documentation for providing a manual mock isn't super clear. Given a setup like: // sound-player.js ...
Read more >How To Do Manual Mock In Jest Unit Testing | by Kris Ma
Jest has two ways to mock functions: Either by creating a mock function to use in test code or writing a manual mock...
Read more >Jest Mocking Strategies | Mercedes Bernard
If you want to learn more, take a look at the Jest docs first ... To create a manual mock, we create a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rickhanlonii Great! i’ll get a PR in as soon as it is ready:) thank you
Edit: thanks for the patience in this. Have been working with non-computer stuff recently:) This is still on my agenda 💯 12/9/2018
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.