React Testing Library - Mock API Calls - Mock Service Worker (msw)

preview_player
Показать описание
A tutorial on how to mock API calls with Mock Service Worker (msw) for writing tests. I'm using React Testing Library along with Jest. I have a video on how to get started with those, here:

React Testing Library - Crash Course

Hope it helps!

Feel free to say hi 👋:

Thanks for watching!

-Andrew

Affiliate links to some of my gear 🤘🙏❤️
(Best quality for the best price from my research)
Рекомендации по теме
Комментарии
Автор

Thanks man, it was a very clear and direct to the point explanation. I've saved so much time researching with this video. Very Impressive!

justindelarapa
Автор

Such an underrated video, the cleanest solution I have found after trying out multiple ways by referring to multiple blogs.
Thanks and Cheers!!

nareshy
Автор

Best video on youtube about mock API. Thanks man

khawajaali
Автор

Finally I found how exactly we need to mock the api's, There is lot of videos for creating react app but
very few teaches how to test it, you nailed it Thanks a lot😊

akrammohammed
Автор

This is what i'm looking for. Thanks a lot bro :)

darmanyaman
Автор

This video was a great timesaver. Thxs a lot for it!

webblocksapp
Автор

Ty all so much for all effort for this great content!

mortezaahmadi
Автор

Thanks so much for this! This just helped me complete a personal milestone for work, integration testing an API-/Redux-powered application.

DerekMontgomery
Автор

Hey man, just wanted to say I watched/read so much on this topic- great job explaining buddy!

yasal
Автор

It was really a helpful video. We encourage you to make more videos.
Thanks and GOOD LUCK.

elvinrajkumar
Автор

Good tutorial, thank you. Helped me. You should specify somewhere where the ../test-utils comes from (maybe provide a link to your other tutorial where you implement this). I found it after some searching. :)

bogdanradoi
Автор

The introduction looks like that is about to start one of that conspiracy videos huashuashuas

rodrigomoura
Автор

Love the Dumb & Dumber clips. I'm too lazy to Google right now, so, what is ctx?

Human_Evolution-
Автор

Hi @Andrew,
content is good and worth to watch as beginners . Could you please create videos for React toolkits api custom hook unit testing example.

PramodKHARADE-yjbf
Автор

awesome dude thx!. Now i have a doubt, try this with pokemon api, i see a error on console, the call excep the timeout of 5000ms. any help?

jogre
Автор

Hi, this might be a silly question. but in test.js file when we render a component how it recognize that response should be getting from this mock setup ?
say if in the component rendered, I have a condition like isLoading, isError, isSuccess and only when isSuccess is true we are returning something . what can I do to test this returned element by this kind of mocking

devathul
Автор

nice video ! very ckear explanation. I have one question though. When you simulate the API response in a GET request, what should I write if my API call returns a json response which is later converted to javascript? For example,

"const response = await fetch(url + api_endpoint, {};

const result = await response.json;


So my question is, what should go inside my ctx.json(), response or result ?

this is for project and any help would be very appreciated!!!

lutallica
Автор

if I want to make a request to it gives me an error. How do I make requests with queryParams?

jeanpablo
Автор

How much does MSW help? Seems like a somewhat complex thing to have to learn. I am scared.

Human_Evolution-
Автор

If I have a log of endpoints like 50-60? It’s gonna be a big array

kirillpavlovskii
visit shbcf.ru