Last active
May 25, 2022 13:09
-
-
Save manjeettahkur/4d58dad193b1745b439826ae7d6a78c7 to your computer and use it in GitHub Desktop.
mock mongoose methods with jest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example how to mock mongoose method internal method | |
| // jest | mongoose | |
| jest.fn().mockImplementationOnce(() => ({ | |
| toObject: jest.fn().mockResolvedValue({id: "2333"}), | |
| lean: jest.fn().mockResolvedValue(null), | |
| })) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment