How to Test Fetch or Axios in a React Component with Mock Service Worker(MSW)

Опубликовано: 27 Сентябрь 2021
на канале: Coding With Adam
12,526
157

In this video we are going to learn how to test a react component that uses a rest API to Get data. The library that we will be using is called Mock Service Worker MSW. Our application is a simple todo application that calls out to a rest api called JSONPlaceholder. Mock Service Worker in my opinion is much cleaner than the traditional way of mocking out the fetch call using Jest.

This method of testing is independent of the library used to communicate with an api. It works for fetch, axios etc.

GitHub

https://github.com/CodingWith-Adam/re...

Mock Service Worker
https://mswjs.io/


Смотрите видео How to Test Fetch or Axios in a React Component with Mock Service Worker(MSW) онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Coding With Adam 27 Сентябрь 2021. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 12,526 раз и оно понравилось 157 посетителям.