Testing In React Tutorial - Jest and React Testing Library

  Рет қаралды 98,029

PedroTech

PedroTech

Күн бұрын

In this video I will be going over testing in react by using Jest and React Testing Library.
Code:
Join our Discord: / discord
🚀 Learn ReactJS By Building 6 Projects: codedamn.com/learn/reactjs-pr...
🐙 GraphQL Course: codedamn.com/learn/graphql-fo...
► Buy Crypto on Coinbase: coinbase-consumer.sjv.io/PedroTech
Social
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Website: machadopedro.com
Linkedin: / machadop1407
Instagram: / _pedro.machado_
Github: github.com/machadop1407
Business Email: pedro@pedrotech.co
Timestamps:
00:00 | Demo
04:03 | Creating tests for components
12:43 | Running tests
22:41 | Using fireEvent
Tags:
- ReactJS Tutorial
- ReactJS and MySQL
- NodeJS Tutorial
- API Tutorial
#reactjs #coding

Пікірлер: 88
@lokers_one
@lokers_one 9 ай бұрын
These tests can produce false negatives and your test won't catch all possible bugs, as you convert string to number. It's very risky in JS world as we all know. For example `Number(false)` produces `0` too. Therefore you wouldn't catch all the bugs. Instead, you should change your assertion to expect to `.toEqual("0")`.
@mayurnagdev5545
@mayurnagdev5545 3 ай бұрын
Thank you this was really helpful
@selfbrilliance9341
@selfbrilliance9341 13 күн бұрын
I was thriving for this, all the videos on youtube just presumed that we know testing and made a bunch of tutorials on how to do testing but because of your video I know "what" and "why" is testing. Thank you ❤
@markganser5485
@markganser5485 Жыл бұрын
Your videos are awesome! I'd love to see some more advanced testing examples on things such as custom hooks, testing where context is present, async functions, and mocking API responses!
@ometman
@ometman 8 ай бұрын
Hey Pedro, thanks for making testing basics very simple.
@mysoregopinathshantanu8800
@mysoregopinathshantanu8800 Жыл бұрын
This helps a lot. And really need more videos on testing.
@SinaTajik
@SinaTajik 11 ай бұрын
The best tutorial for learning react unit test super simple and straight forward :)
@willmann96
@willmann96 10 ай бұрын
thank you for the clear and concise information.
@ThColinPereira
@ThColinPereira Жыл бұрын
Great video Pedro! Super helpful
@travelglobe8997
@travelglobe8997 6 ай бұрын
You got a new subscriber. Simple and on point. Good video bro.
@parvathyvd
@parvathyvd Жыл бұрын
Thanks a lot Pedro :) Another useful video. You keep helping us.
@NikhilPawar151
@NikhilPawar151 5 ай бұрын
Thank you for valuable content. This video clear my concept about testing in react.
@MehediHassan-pn5uc
@MehediHassan-pn5uc Жыл бұрын
Dude you're a underrated Gem! ❤️
@vandanavishnu1922
@vandanavishnu1922 Жыл бұрын
Your Videos are very informative. I was able to answer lot of questions in my interview with just watching your videos( react hooks). Now I am watching this . I am sure it will definitely help me...Thanks a lot..
@PedroTechnologies
@PedroTechnologies Жыл бұрын
Best of luck!
@ankitkumarsharma2372
@ankitkumarsharma2372 Жыл бұрын
Well, It's on exact time. I am going to start to learn Testing in react
@psydook
@psydook Жыл бұрын
Hey, thanks for the video! Can you also do one which is like a Coding Interview in React from Begginer to Advanced with something like some typescript concepts included ? I think this will benefit alot of people who are preparing for coding interviews. Thanks again !
@chaitanyasawant776
@chaitanyasawant776 Жыл бұрын
Great topic. Make more videos on this topic
@universecode1101
@universecode1101 Жыл бұрын
Great topic Pedro, super useful for any developer ✌🏻
@PedroTechnologies
@PedroTechnologies Жыл бұрын
Thank you!!
@neverexecute2467
@neverexecute2467 Жыл бұрын
This video is awesome and helps a lot, I also need create a dynamic XML sitemap and HTML sitemap in React
@LeslieDuan
@LeslieDuan Жыл бұрын
thank you so much, hope to see tutorial about cypress
@rodrigocastro3934
@rodrigocastro3934 7 ай бұрын
Great video Pedro. It would be nice to have the 'advanced' version where testing state changes by clicking buttons ;))
@filipevalentegomes2383
@filipevalentegomes2383 Жыл бұрын
That’s so funny, I was gonna take a course for this today, haven’t done testing in a while. Thanks for the video
@SharukhKhan-sd7xg
@SharukhKhan-sd7xg Жыл бұрын
Which course are you going to buy?
@PedroTechnologies
@PedroTechnologies Жыл бұрын
Hahahaha hope this video helps! Im planning on making a crash course on it!
@filipevalentegomes2383
@filipevalentegomes2383 Жыл бұрын
@@PedroTechnologies awesome. Keep up the good work.
@SharukhKhan-sd7xg
@SharukhKhan-sd7xg Жыл бұрын
@@PedroTechnologies yes need that one
@filipevalentegomes2383
@filipevalentegomes2383 Жыл бұрын
@@PedroTechnologies 13 min10 sec, there is an edit mistake I think. It jumps from on frame to another. Not sure if you know about that
@ggwellplayed4568
@ggwellplayed4568 Жыл бұрын
Continue sharing your knowledge. God will take care fo you. Thanks dude ;)
@tootyrnt5533
@tootyrnt5533 6 ай бұрын
Nice video, would be cool to show how this can be set up with Vite + React.
@sodhigurpreetsingh
@sodhigurpreetsingh Жыл бұрын
Great video again pedro.. can you make a video on Formik or any other library you know is best for forms..
@OPlutarch
@OPlutarch Жыл бұрын
Thanks! Can you make more videos about testing? I think that it's a topic that a lot of us we need to improve :) Greetings.
@PedroTechnologies
@PedroTechnologies Жыл бұрын
For sure!
@omarelgnn7344
@omarelgnn7344 Жыл бұрын
@@PedroTechnologies yes this presentation of how to test the component or what should be tested and the component that renders data from API and so on Thanks for all
@mohitdhule9654
@mohitdhule9654 Жыл бұрын
Thank you 🙏
@GlennMartin
@GlennMartin Жыл бұрын
Pedro my man, how about testing forms and components that fetch data. Would like to learn how to mock them.
@salonipande6190
@salonipande6190 Жыл бұрын
@Pedro Tech can you please share the playlist of this course
@kranthikumar5215
@kranthikumar5215 Жыл бұрын
Love you pedro❤
@amanjat7
@amanjat7 14 күн бұрын
Helpful
@JaredFL
@JaredFL Жыл бұрын
I'd like to see a Webpack beginner video :)
@turing4991
@turing4991 Жыл бұрын
You should try to make a video on publishing a react component. Publishing a hook is easy.
@karis7539
@karis7539 Жыл бұрын
i personally love testing because i love automating things with Selenium or Playwright
@cubedesigne
@cubedesigne Жыл бұрын
Thanks your video!!!
@drawingdr9829
@drawingdr9829 Жыл бұрын
hello bro thanx for your videos we are really benefit from them. you deployed react node mysql app in heroku but it very expansive . can you do a tutorial about deploy it in digital ocean? thank you
@brilliantatosam6882
@brilliantatosam6882 Жыл бұрын
Awesome content
@bananablu47
@bananablu47 Жыл бұрын
Hey what is const { getByTestId } around 9:00 at line 6 ? An anonymous const?
@azizkhujakhujaev2598
@azizkhujakhujaev2598 Жыл бұрын
Nice video and can you please make a video about React Native testing library and in advance thanks!
@Popo-hr6gc
@Popo-hr6gc Жыл бұрын
What VSCode theme are u using?
@waleedsharif618
@waleedsharif618 Жыл бұрын
Could you show jest --coverage And how to get 100% test coverage ?
@DaltonLaboratories
@DaltonLaboratories 6 ай бұрын
I would rather use "test" over "it" in your examples. The second one is an alias and it reads better only when you name your tests like this: 'it("should do something.."), it("should display the counter")' etc. Nevertheless, good tutorial, thanks!
@robertvelasquez8641
@robertvelasquez8641 9 ай бұрын
what if i use vite?
@shishirrai1069
@shishirrai1069 Жыл бұрын
Please make video on jest and enzyme
@tsdineshjai8565
@tsdineshjai8565 Жыл бұрын
Hey Pedro 👋, if possible do a crash course on this topic
@PedroTechnologies
@PedroTechnologies Жыл бұрын
Yes, thats on the plans!
@graycoder9911
@graycoder9911 5 ай бұрын
I only know of two great developers Ben awad and pedrotech
@suvendukumarsahoo4172
@suvendukumarsahoo4172 Жыл бұрын
He can u have idea testing for post api
@karthikbalaji383
@karthikbalaji383 Жыл бұрын
I have never done testing before so can anyone tell me how percentage of the testing concepts are covered in this video.
@dylanheslop9161
@dylanheslop9161 4 ай бұрын
how can this be done with ts and vite
@internetexplorer7880
@internetexplorer7880 Жыл бұрын
What vscode theme is this?
@harishg9429
@harishg9429 Жыл бұрын
Can you pls make a video on testing components mocking API , also testing state. Thanks
@PedroTechnologies
@PedroTechnologies Жыл бұрын
I can fs make one! Testing states is not that good imo, i would rather just spy on the state function and test its functionality bc states dont update equally. Also, testing should be for testing how the UI changes, not how the internal logic acts :)
@harishg9429
@harishg9429 Жыл бұрын
@@PedroTechnologies Thank you Pedro, I like all your videos, they are easy to follow and highly educational.
@ankitchauhan8682
@ankitchauhan8682 Жыл бұрын
How is he using jsx with. Js extension?
@christianlewis7055
@christianlewis7055 Жыл бұрын
Weird feedback: that habit of repeatedly highlighting the test while you're busy talking is satisfying only as long as you repeatedly highly exactly the correct area. Like if you start highlighting a string, as long as you start at the opening double quote and finish exactly after the closing quote, I find it satisfying and might actually help to retain my interest. But if you don't hit the mark just right, it will bother me. 😄
@xman3666
@xman3666 Жыл бұрын
If i have a componente such a “loading” using lazy render react. How can I test the elements that come after the loading? 😢
@Way_Of_The_Light
@Way_Of_The_Light Жыл бұрын
ask ChatGPT
@primy3576
@primy3576 Жыл бұрын
vs code theme?
@ranza658
@ranza658 Жыл бұрын
Is source code available for this video?
@gmmkeshav
@gmmkeshav 11 ай бұрын
code of this video?
@bradenmitchell3265
@bradenmitchell3265 Жыл бұрын
Deja vu @ 13:09?
@PedroTechnologies
@PedroTechnologies Жыл бұрын
Thank you for letting me know! This was a mistake on the editing!
@demarbrown439
@demarbrown439 7 ай бұрын
13:00
@patrykK1028
@patrykK1028 Жыл бұрын
There's no link to the code :/
@WydeZ
@WydeZ 10 ай бұрын
where is the code
@cometarioxD
@cometarioxD Жыл бұрын
Watch out folks, if you're getting the error message, look for EVERY syntax error possible!
@reactDevelopment
@reactDevelopment 11 ай бұрын
can you make avideo on these act() mockComponent() isElement() isElementOfType() isDOMComponent() isCompositeComponent() isCompositeComponentWithType() findAllInRenderedTree() scryRenderedDOMComponentsWithClass() findRenderedDOMComponentWithClass() scryRenderedDOMComponentsWithTag() findRenderedDOMComponentWithTag() scryRenderedComponentsWithType() findRenderedComponentWithType() renderIntoDocument() Simulate
@arihantjain8347
@arihantjain8347 Жыл бұрын
It wasn't in round figure, stuck at 999, so I made it 1K.
@thevasupodcast4561
@thevasupodcast4561 Жыл бұрын
Hey i noticed that here you are using a derived state, which is not best practice. You should move the state to a higher level component.
@Human_Evolution-
@Human_Evolution- Жыл бұрын
I cannot reproduce this on my app at all. I hate this video. I hate testing. I watch you all the time and love your channel but testing has me so bitter I am downvoting you.
@christopherfoley4355
@christopherfoley4355 Жыл бұрын
lol wow
@thegohmez6816
@thegohmez6816 Жыл бұрын
WOW GRAPE.
@Den1sNovikov
@Den1sNovikov 3 ай бұрын
How I suppose to do it with you, if u are not sharing starting demo code?))) Dislike.
@456fghbsrtywrtwre
@456fghbsrtywrtwre 10 ай бұрын
Awesome video. It has helped me a lot already. There is an issue for later versions. Just add screen.getByTestId instead of getByTestId and you are good to go. For getByRole as well.
React Testing Tutorial with React Testing Library and Jest
41:43
How to Test In React - React Testing Library + Jest Tutorial
31:46
Мы играли всей семьей
00:27
Даша Боровик
Рет қаралды 4 МЛН
НЕОБЫЧНЫЙ ЛЕДЕНЕЦ
00:49
Sveta Sollar
Рет қаралды 7 МЛН
React Testing Crash Course
58:36
Traversy Media
Рет қаралды 311 М.
Next.js with React Testing Library, Jest, TypeScript
25:04
Dave Gray
Рет қаралды 48 М.
Test-Driven Development // Fun TDD Introduction with JavaScript
12:55
This is the Only Right Way to Write React clean-code - SOLID
18:23
Introduction To Testing In JavaScript With Jest
13:57
Web Dev Simplified
Рет қаралды 483 М.
You Need React Query Now More Than Ever
11:04
Theo - t3․gg
Рет қаралды 136 М.
NestJS Tutorial For Beginners - Learn NestJS
51:49
PedroTech
Рет қаралды 1,1 М.
Jest Crash Course - Learn How to Test your JavaScript Application
1:06:53
React Unit Testing Tutorial With React Testing Library and Vitest React
19:12
Monsterlessons Academy
Рет қаралды 8 М.
🤯Самая КРУТАЯ Функция #shorts
0:58
YOLODROID
Рет қаралды 3,4 МЛН
Apple Event - May 7
38:22
Apple
Рет қаралды 6 МЛН
📱 SAMSUNG, ЧТО С ЛИЦОМ? 🤡
0:46
Яблочный Маньяк
Рет қаралды 781 М.
3D printed Nintendo Switch Game Carousel
0:14
Bambu Lab
Рет қаралды 1,6 МЛН
Рекламная уловка Apple 😏
0:59
Яблык
Рет қаралды 806 М.