Mock Axios with Jest and React Testing Library in Typescript (React)

Have you been using Typescript in your React project lately ? Jest and React Testing Library are your go to tool for writing tests ? And you are having issues trying to test an async method that fetches data from an api using axois ?

Is that a YES ?

Then my friend, you are in right place. I hope this will solve the problem you are facing and you can get that break you’ve been meaning to take.

Let’s get started 👨🏻‍💻

Scenario

We’re going to write a method that uses to make an HTTP Get request from…

Anish

Software Engineer | Musician | Illustrator

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store