Skip to content

Instantly share code, notes, and snippets.

@manjeettahkur
Last active May 25, 2022 13:09
Show Gist options
  • Select an option

  • Save manjeettahkur/4d58dad193b1745b439826ae7d6a78c7 to your computer and use it in GitHub Desktop.

Select an option

Save manjeettahkur/4d58dad193b1745b439826ae7d6a78c7 to your computer and use it in GitHub Desktop.
mock mongoose methods with jest
// 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