[new rule] prefer jest.doMock
See original GitHub issueI have found using jest.doMock
over jest.mock
works better because it is predictable and works well with resetMocks
, resetModules
and restoreMocks
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (10 by maintainers)
Top Results From Across the Web
The Jest Object
Creates a new mock function. The new function has no formal parameters and when called will return undefined . This functionality also applies ......
Read more >Difference between jest.mock and jest.doMock - Stack Overflow
jest.mock is hoisted above import when used at top level and hoisted to the the beginning of the block when used in a...
Read more >Jest Object (API Reference) - w3resource
It will create a new mock function. The new function will have no formal parameters and when called returns undefined. This functionality will ......
Read more >Mocking React hooks when unit testing using Jest
A general rule I like to follow is to mock only the edges of your app and these are the points of contact...
Read more >Testing Jest Problem: Cannot mock and unmock in the same file
My solution was to create a new file just to test the catch block. ... Sounds like exactly the use case for jest.doMock....
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 FreeTop 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
Top GitHub Comments
It won’t work with
import
as they’re hoisted to the top level. I’m not against adding a rule for it, though 🙂Am closing per my previous comment