DEV Community

Discussion on: The only 3 steps you need to mock an API call in Jest

Collapse
adrienjoly profile image
Adrien Joly

Thanks for the very clear explanation, Zak!
I would like to mention two additional ways to mock:

  • mock the API responses at the HTTP level, to make the test agnostic to the library used to send those requests. E.g. « nock »
  • use dependency injection in your code, do you can inject a mock directly from your test, without having to rely on jest for this.