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!
@techcheck30422 жыл бұрын
Thank you! Glad it helped!
@nareshy9903 жыл бұрын
Such an underrated video, the cleanest solution I have found after trying out multiple ways by referring to multiple blogs. Thanks and Cheers!!
@techcheck30423 жыл бұрын
Wow, thank you so much!! 🙏🙏
@khawajaali4442 жыл бұрын
Best video on youtube about mock API. Thanks man
@techcheck30422 жыл бұрын
Wow, thanks so much! 🙏
@akrammohammed35812 жыл бұрын
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😊
@techcheck30422 жыл бұрын
Thanks so much! And thank you for watching! 🍻
@akrammohammed35812 жыл бұрын
Please make a blog how to add code coverage threshold for react app
@poenaeco5 ай бұрын
thanks for the vid, helped a lot.
@techcheck30425 ай бұрын
@@poenaeco glad it helped! Thanks for the comment!
@darmanyaman8234 Жыл бұрын
This is what i'm looking for. Thanks a lot bro :)
@techcheck3042 Жыл бұрын
Awesome to hear! Thanks for watching!
@DerekMontgomery2 жыл бұрын
Thanks so much for this! This just helped me complete a personal milestone for work, integration testing an API-/Redux-powered application.
@techcheck30422 жыл бұрын
That's so awesome to hear! You are very welcome and glad it helped!
@mortezaahmadi57102 жыл бұрын
Ty all so much for all effort for this great content!
@techcheck30422 жыл бұрын
Thanks for the awesome comment and thank you for watching! Glad it helped!
@webblocksapp Жыл бұрын
This video was a great timesaver. Thxs a lot for it!
@techcheck3042 Жыл бұрын
Awesome to hear! Glad it helped!
@yasal99572 жыл бұрын
Hey man, just wanted to say I watched/read so much on this topic- great job explaining buddy!
@techcheck30422 жыл бұрын
Thank you! 🙏 And thank you for watching!
@jogre900 Жыл бұрын
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?
@techcheck3042 Жыл бұрын
What does the error say?
@devathul2 жыл бұрын
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
@techcheck30422 жыл бұрын
You would mock the api call and the response (mock a successful response in this case) in that handlers array. Then, in the test file, you'd write a test and test for the returned element. That part is more about implementing a test with React Testing Library. I have a video for that here: kzbin.info/www/bejne/gXPLeXl5Yr-ke6s Hope that helps!
@devathul2 жыл бұрын
@@techcheck3042 oh yes ... Now I got it . So basically how this msw work is when the api call happens , MSW interceps that request and gives us whatever mock data we specified . So that we don't need to mention to get data from mock setup . Right?
@khalidm59392 жыл бұрын
Thanks man very helpful!
@techcheck30422 жыл бұрын
Glad to hear! Thanks for watching!
@6av3212 жыл бұрын
Learned a lot. Thanks man.
@techcheck30422 жыл бұрын
Glad to hear it! Thanks for watching
@6av3212 жыл бұрын
@@techcheck3042 Would there be a github repo or one of your blogs that I can see the source code? Thank you.
@Human_Evolution-2 жыл бұрын
How much does MSW help? Seems like a somewhat complex thing to have to learn. I am scared.
@techcheck30422 жыл бұрын
Haha it's not that bad. Once it's setup, you can just slowly add to it as you make more API calls in your application 👍
@Human_Evolution-2 жыл бұрын
@@techcheck3042 nice. I spent 3 hours trying to write a test today and just failed at every attempt. I spent the last week studying tests but can't seem to get anything to click. I'm like 30 hours in on 1 test file with no meaningful tests written.
@techcheck30422 жыл бұрын
@@Human_Evolution- ah, sorry to hear! I have definitely been there lol. Are you using React? I have a good starter video for testing with React Testing Library here: kzbin.info/www/bejne/gXPLeXl5Yr-ke6s and some other videos for if you have issues with Redux when testing. Hope that helps! I definitely had to go back and forth between videos and documentation before I started to get it
@Human_Evolution-2 жыл бұрын
@@techcheck3042 Ah KZbin logic is deleting all my comments. I guess we are not allowed to paste code.
@Human_Evolution-2 жыл бұрын
@@techcheck3042 I do not think we have to use a handlers dot js file. I just put 4 handlers/POST, GET, PUT, & DELETE in my service worker, and it works! I am all for using less files. But my web app is super super simple, so maybe handlers make sense with something more complicated.
@elvinrajkumar4772 жыл бұрын
It was really a helpful video. We encourage you to make more videos. Thanks and GOOD LUCK.
@techcheck30422 жыл бұрын
Thanks so much! I certainly will!
@amirrezaart2 жыл бұрын
Very useful👍
@techcheck30422 жыл бұрын
Glad to hear it! Thank you!
@devmrin3 жыл бұрын
Thanks this is brilliant 🙌
@techcheck30423 жыл бұрын
Thank you! 🙏
@lutallica833 жыл бұрын
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; dispatch(fetchSuccess(result)); 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!!!
@techcheck30423 жыл бұрын
ctx.json() returns json. You can also do ctx.body() or ctx.data(). If you typically have to convert it to json after you get your response back, I would assume you'll need ctx.body(). It depends on your particular response. You can also look at the documentation under API, then context. Hope this helps!
@arturoalvarez26463 жыл бұрын
@@techcheck3042 Thanks. Very helpful!
@kirillpavlovskii83422 жыл бұрын
If I have a log of endpoints like 50-60? It’s gonna be a big array
@Krazness2 жыл бұрын
Consider splitting the endpoints into diff files, then importing them into the handlers.js
@rodrigomoura21082 жыл бұрын
The introduction looks like that is about to start one of that conspiracy videos huashuashuas
@techcheck30422 жыл бұрын
😂😂😂
@Human_Evolution-2 жыл бұрын
Love the Dumb & Dumber clips. I'm too lazy to Google right now, so, what is ctx?
@bogdanradoi19632 жыл бұрын
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. :)
@techcheck30422 жыл бұрын
Ah, good point. Thanks for watching! Glad it helped :)
@amazinginterestingstuff94133 жыл бұрын
i keep getting: Unexpected reserved word 'await'. (114:11) Any ideas?
@techcheck30423 жыл бұрын
Await is a keyword that is paired with async. Did you use the async keyword to declare the function as async? const fetch = async () => { await result = response.data ... }
@amazinginterestingstuff94133 жыл бұрын
@@techcheck3042 hehe yes got it now, just an hour ago! on to new issues now :)
@techcheck30423 жыл бұрын
@@amazinginterestingstuff9413 Haha such is coding 😂. Glad you got it!
@jeanpablo10312 жыл бұрын
if I want to make a request to '${baseURL}/something?someParam=x' it gives me an error. How do I make requests with queryParams?
@6basculante3 жыл бұрын
How to mock with firebase?
@techcheck30423 жыл бұрын
It would be the same setup. Whatever api/url you use to reach out to firebase, you would put that in the msw handlers: rest.get("firebase.backend.com/data", (req, res, ctx) => { return res(ctx.match response here) }
@PramodKHARADE-yj7bf Жыл бұрын
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.