Testing In React Tutorial - Jest and React Testing Library
ฝัง
- เผยแพร่เมื่อ 30 มิ.ย. 2024
- 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 - วิทยาศาสตร์และเทคโนโลยี
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 ❤
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!
Hey Pedro, thanks for making testing basics very simple.
Dude you're a underrated Gem! ❤️
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")`.
Thank you this was really helpful
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..
Best of luck!
Great video Pedro! Super helpful
Great topic Pedro, super useful for any developer ✌🏻
Thank you!!
This helps a lot. And really need more videos on testing.
You got a new subscriber. Simple and on point. Good video bro.
thank you for the clear and concise information.
Thanks a lot Pedro :) Another useful video. You keep helping us.
The best tutorial for learning react unit test super simple and straight forward :)
Thank you for valuable content. This video clear my concept about testing in react.
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 !
Well, It's on exact time. I am going to start to learn Testing in react
This video is awesome and helps a lot, I also need create a dynamic XML sitemap and HTML sitemap in React
Great topic. Make more videos on this topic
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.
For sure!
@@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
That’s so funny, I was gonna take a course for this today, haven’t done testing in a while. Thanks for the video
Which course are you going to buy?
Hahahaha hope this video helps! Im planning on making a crash course on it!
@@PedroTechnologies awesome. Keep up the good work.
@@PedroTechnologies yes need that one
@@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
Great video Pedro. It would be nice to have the 'advanced' version where testing state changes by clicking buttons ;))
thank you so much, hope to see tutorial about cypress
Thank you 🙏
Nice video, would be cool to show how this can be set up with Vite + React.
Continue sharing your knowledge. God will take care fo you. Thanks dude ;)
Thanks your video!!!
Great video again pedro.. can you make a video on Formik or any other library you know is best for forms..
Helpful
Awesome content
Love you pedro❤
i personally love testing because i love automating things with Selenium or Playwright
You should try to make a video on publishing a react component. Publishing a hook is easy.
I'd like to see a Webpack beginner video :)
Pedro my man, how about testing forms and components that fetch data.
Would like to learn how to mock them.
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!
@Pedro Tech can you please share the playlist of this course
Nice video and can you please make a video about React Native testing library and in advance thanks!
I only know of two great developers Ben awad and pedrotech
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
Hey Pedro 👋, if possible do a crash course on this topic
Yes, thats on the plans!
Hey what is const { getByTestId } around 9:00 at line 6 ? An anonymous const?
Could you show jest --coverage And how to get 100% test coverage ?
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. 😄
Please make video on jest and enzyme
Can you pls make a video on testing components mocking API , also testing state. Thanks
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 :)
@@PedroTechnologies Thank you Pedro, I like all your videos, they are easy to follow and highly educational.
What VSCode theme are u using?
I have never done testing before so can anyone tell me how percentage of the testing concepts are covered in this video.
What vscode theme is this?
How is he using jsx with. Js extension?
If i have a componente such a “loading” using lazy render react. How can I test the elements that come after the loading? 😢
ask ChatGPT
how can this be done with ts and vite
He can u have idea testing for post api
what if i use vite?
Watch out folks, if you're getting the error message, look for EVERY syntax error possible!
vs code theme?
Is source code available for this video?
13:00
Deja vu @ 13:09?
Thank you for letting me know! This was a mistake on the editing!
There's no link to the code :/
It wasn't in round figure, stuck at 999, so I made it 1K.
code of this video?
where is the code
can you make avideo on these
act()
mockComponent()
isElement()
isElementOfType()
isDOMComponent()
isCompositeComponent()
isCompositeComponentWithType()
findAllInRenderedTree()
scryRenderedDOMComponentsWithClass()
findRenderedDOMComponentWithClass()
scryRenderedDOMComponentsWithTag()
findRenderedDOMComponentWithTag()
scryRenderedComponentsWithType()
findRenderedComponentWithType()
renderIntoDocument()
Simulate
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.
Who uses js in 2023???
I make videos in js bc it is more easily understandable by a wider audience. Someone who knows ts, understands js. Whilst someone who knows js doesn't necessarily know ts. If the point of the video is not the ts syntax, I prefer to use javascript since more people can understand it :)
*I think you meant 2024
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.
lol wow
WOW GRAPE.
How I suppose to do it with you, if u are not sharing starting demo code?))) Dislike.
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.