Тёмный
No video :(

Mocking React Components and Functions using Jest for Beginners - React.js Testing Tutorial #5 

Bruno Antunes
Подписаться 22 тыс.
Просмотров 56 тыс.
50% 1

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 77   
@aolausoro2942
@aolausoro2942 2 года назад
Hi Brune, Really find this tutorials on testing helpful especially for a beginner into testing like me. Could you recommend another means of mocking react components as mocked - ts-jest/utils has been deprecated?😁
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
That's awesome to know my friend 😍 Yes, absolutely, It was deprecated 12 days ago =D Basically ts-jest/utils is now deprecated because it was moved (copy pasted) from ts-jest to jest itself (which is great news if you ask me) You'll be able to do ``` jest.mocked(SomeComponent) ``` and it works exactly as before, because it's the exact same code :) Just keep in mind that there was a mistake in that Pull Request and they forgot to export the mocked function. They have now a new PR opened, but not merged yet: PR: github.com/facebook/jest/pull/12133 Issue: github.com/facebook/jest/issues/12131 If you give them a few more days, then you can move from ts-jest/utils to jest itself :)
@aolausoro2942
@aolausoro2942 2 года назад
@@BrunoAntunesPT Hi Bruno, Thanks for the quick response. I’ll take your advise and wait a few more days. 😁
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
@@aolausoro2942 yeah, I will be doing a "find and replace" kind of job when they merge that one 😅😅😅 For now, nothing to worry about 😉😉 just subscribe to that GitHub issue/PR and when it gets merged it's party time 😂😂😂
@arpanbanejee5143
@arpanbanejee5143 Год назад
@@BrunoAntunesPT Thank you for the awesome tutorial! I have learnt a lot from this single video and I can contribute directly to my project. However, jest.mocked() still does not work jest.mock('material-table', () => ({ ...jest.requireActual('material-table'), MaterialTable: jest.fn(() => Table), })); const mockedMaterialTable = jest.mocked(MaterialTable); ● Test suite failed to run TypeError: jest.mocked is not a function 35 | })); 36 | > 37 | const mockedMaterialTable = jest.mocked(MaterialTable); | ^ This is the error I am getting. Can you please help me with this?
@dannyroberts4067
@dannyroberts4067 2 года назад
Thank the lord for this guy 👏I'm a junior dev' and I started working for a big company three months ago. I had no experience of testing and it has severely affected my performance in this role, I wish I had have seen this video two months ago but it's still useful for me. Lots of other jest videos out there are good, but pretty basic, this one is up to date and exactly how my company mocks so cheers Bruno. P.s. I know it sounds like I'm this dude's friend giving him a nice review, but I don't care this video is deffo worth it for anyone who doesn't have a goosy about testing like myself a short while ago.
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you very much for your words Danny ❤️😍
@adetolaisaiah391
@adetolaisaiah391 2 года назад
Hmmm this comment has inspired me to watch
@arpanbanejee5143
@arpanbanejee5143 Год назад
Rightly said! This covers the concepts which we actually require in our day-to-day work in the company projects.
@mithderlersam
@mithderlersam 2 года назад
Hi Bruno, there are lots of testing tutorials on youtube but your tutorials are one of the best. Thank you for your great explanations. You took a break from youtube videos, I think you should continue. We're waiting for your new videos.
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you very very much for your words 🙂 currently I don't have the time to publish, but hopefully one day I'll be able to come back to RU-vid 😍
@algodork
@algodork 3 года назад
This is the best testing video I've ever seen!
@BrunoAntunesPT
@BrunoAntunesPT 3 года назад
Thank you very much =D
@GfastGao
@GfastGao 2 года назад
Super professional tutorial I've seen so far. Really many practical tricks explained here which our team spent years to figured out with Jest. Still looking for a trick to save memory when jest is running.
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you very much 😍 regarding memory I have never faced anything too bad (probably having 32gb of ram helps me 😅😅)
@hillelgarcia5140
@hillelgarcia5140 Месяц назад
Amazing tutorial, better than the jest documentation itself, mocks are so powerful!
@PraveenKumar-ft2kr
@PraveenKumar-ft2kr 2 года назад
You gave my motivation back brother... Thank you so much :) So happy that i found your channel :)
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
So happy to read that my friend 😍😍
@qram04
@qram04 2 года назад
This is by far the best tutorial on mock/spy that i have found. Thanks
@lucadifazio2735
@lucadifazio2735 2 года назад
Finally, I've understood what spying and mocking is! Thanks!!!!
@makstarr666
@makstarr666 3 года назад
Thank you Bruno for this wonderful series! 🤓👍👍👍
@BrunoAntunesPT
@BrunoAntunesPT 3 года назад
Thank you very much 😊❤️ Monday we will have video 6, showing how to mock http calls using msw 😊
@paulpardee
@paulpardee 2 года назад
Oh my gosh, I spent all day yesterday looking at articles on how to do this and got nowhere. 6 minutes into your video and I have a passing test! Thanks!
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
I'm sorry to hear that you spent a day looking for this information. On a positive note, I'm very happy you found value in my video 😍😍😍 thank you very much ❤️
@SemenAlexndrovich
@SemenAlexndrovich 2 года назад
Thank you so much! Your manner of explanation is great!
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Glad you think so!
@moibe182
@moibe182 Год назад
El mejor tutorial de pruebas que he visto en la red. Te agradezco muchísimo Bruno!!
@AnzarDtafukt
@AnzarDtafukt 2 года назад
Liking this before watching. Been a while since I have found one of your videos.
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you very much - I hope you have enjoyed the video after watching it 😅
@AnzarDtafukt
@AnzarDtafukt 2 года назад
@@BrunoAntunesPT Always.
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
so good to read your comment 😍😍 once again, thank you very very much 🤗
@vittoriomorellini1939
@vittoriomorellini1939 Год назад
This is an amazing series on test. Simply wonderfull
@rezaverse
@rezaverse 2 года назад
Love your presentation man. awesome !!!
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you 🤗
@mrjebbar
@mrjebbar 2 года назад
What a great video. Thanks for putting this together. Nice and clear
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you ❤️
@gabrielfrancelino2389
@gabrielfrancelino2389 Год назад
Excellent explanation, you gained another subscriber, congratulations!
@GG-uz8us
@GG-uz8us 2 года назад
Very helpful, esp the last trick. Thank you.
@AkinBelieve
@AkinBelieve 2 года назад
This guy is something else...
@lix5694
@lix5694 Год назад
Excellent explanation. Thanks!
@ghostpieces2362
@ghostpieces2362 2 года назад
Loved it, Thank you :)
@CodeWithEasyFaris
@CodeWithEasyFaris Год назад
Thanks awesome tutorial
@sashaikevich
@sashaikevich Год назад
Really helpful as always Bruno. Thank you !
@curiousprogrammer90
@curiousprogrammer90 3 года назад
Very useful tips! Thanks! :)
@BrunoAntunesPT
@BrunoAntunesPT 3 года назад
I'm happy I could help 😊
@deadlock107
@deadlock107 2 года назад
This is very informative! Thank You!
@0xPanda1
@0xPanda1 3 года назад
You videos are so great ☺️
@BrunoAntunesPT
@BrunoAntunesPT 3 года назад
Thank you very much Alii ❤️
@sueluceromartinezherrera1825
Hello, this is pretty clear and helpful, just one question , what happen if I m not using typescript, in minute 12 more or less you used mocked() that comes from ac ts library, I did not understand it a lot, if it is a normal js file how can I use it? :)
@oleksandr5128
@oleksandr5128 3 года назад
That was good! Will we have a video about mocking HTTP calls from the component. Or basically, this is the same as mocking async func calls that you described in the previous videos
@BrunoAntunesPT
@BrunoAntunesPT 3 года назад
Thank you very much my friend 😍 That will be Monday's video (video 6) 😊 we will be using msw (mock service worker) to help us mocking the http calls, then as you said, we will use also the concepts learned in Video 4 (async testing) 😊
@mateustorquato5370
@mateustorquato5370 Год назад
Hey man, nice video, thanks a lot for it. I'd like to know if you know how to deal with a situation that I have the component displayed twice or more inside a component, and I want to validate the params sent to both? Like: How would I test those two components separately if when I mock it, I mock both at the same time? I appreciate man =) The way you explain is simple and didactic, loved it.
@arventures6181
@arventures6181 2 года назад
Thanks bro!
@RaviKumar-hz8cf
@RaviKumar-hz8cf 6 месяцев назад
Can i use jest.spy on in different js which is not my test file file or we have to use it in only test.js file and inside describe and test block only.
@raviranjan6414
@raviranjan6414 6 месяцев назад
Awesome
@oscargm1979
@oscargm1979 2 года назад
So awesome materiallll broooo
@attamjotsingh4474
@attamjotsingh4474 2 года назад
Hey Bruno, awesome video, you mocked the Dataggrid with mocked function from ts-grid, but I am not using typescript in my project. How to mock it then and also what is the significance of mocking here with ts-grid when you are mocking it with jest.mock ??
@thaungthanhan5928
@thaungthanhan5928 2 года назад
Thank you for this great instruction. By the way, Does the same concept apply to the react native applications?
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you 🎉 uhhhhh good question... I have never used react native. I would assume yes, but I might be massively wrong 😅
@BrainwavesPotential
@BrainwavesPotential 2 года назад
Hi Bruno, thank you for posting this for us! I really like your tutorials. May I ask one question: Why do you use "mocked" from "ts-utils" for mocking the DataGrid, but it was not necessary for mocking the VeryComplex component? When do I know if I need to use the "mocked" from ts-utils? Thanks!
@suvendukumarsahoo4172
@suvendukumarsahoo4172 Год назад
are u get it?? if yes, plz explain wht to do?
@CristianRodriguez-zn4wp
@CristianRodriguez-zn4wp 2 года назад
Thanks!
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you soo soo much Cristian 😍❤️
@shrkawy
@shrkawy 3 года назад
first comment 😂😍
@BrunoAntunesPT
@BrunoAntunesPT 3 года назад
Thank you 😍
@AlbertoPNeto
@AlbertoPNeto 2 года назад
Great video! But I have a problem. What do I use instead of the "mocked" function, given I'm not using Typescript and therefore am not using "ts-jest/utils"? Thanks
@suvendukumarsahoo4172
@suvendukumarsahoo4172 Год назад
are u get it?? if yes, plz explain wht to do?
@andriyvozniuk5854
@andriyvozniuk5854 2 года назад
Hello Bruno! Your video is so helpful, thx! I have one question. Can I mock my own component or component from any library only in specific tests? Cause now I unfortunately didn’t find a correct way and my solution is to create two test files with mock and without, so, it is no a better solution 😄
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you very much 😍 When you do jest.mock you are mocking that dependency for all the tests in that file. I honestly never found a use case where inside the same file I want to have mocks for some tests and no mocks for other tests - but it's very possible that I'm understanding your request in a wrong way 😅
@dannyroberts4067
@dannyroberts4067 2 года назад
Thanks
@BrunoAntunesPT
@BrunoAntunesPT 2 года назад
Thank you :)
@ricardocosta4663
@ricardocosta4663 3 года назад
Second first comment 😋
@BrunoAntunesPT
@BrunoAntunesPT 3 года назад
Ahah 😅 second first 😂 thank you Ricardo ❤️
@Kevin-yw5qr
@Kevin-yw5qr 3 года назад
Thanks!
@BrunoAntunesPT
@BrunoAntunesPT 3 года назад
You are amazing Kevin ❤️ thank you very much 😍
Далее
Mocking Asynchronous Functions with Jest
21:50
Просмотров 70 тыс.
Аруси Точики ❤️❤️❤️
00:13
Просмотров 150 тыс.
Friends
00:32
Просмотров 177 тыс.
when you have plan B 😂
00:11
Просмотров 5 млн
If __name__ == "__main__" for Python Developers
8:47
Просмотров 400 тыс.
Thoughts About Unit Testing | Prime Reacts
11:21
Просмотров 222 тыс.
Mock vs Spy in Testing with Jest: Which is Better?
25:12
Mocking Axios in Jest + Testing Async Functions
17:43
Brutally honest advice for new .NET Web Developers
7:19
JavaScript Testing - Mocking Async Code
18:05
Просмотров 145 тыс.
I've been using Redis wrong this whole time...
20:53
Просмотров 356 тыс.
React unit testing with Jest & React-testing-library
23:49
Аруси Точики ❤️❤️❤️
00:13
Просмотров 150 тыс.