React Testing for Beginners: Start Here!

Поділитися
Вставка
  • Опубліковано 8 чер 2024
  • Ready to master React testing? This tutorial covers the essentials of React Testing Library with Vitest / Jest. Get hands-on and start writing better tests today!
    🚀 Want to take your skills to the next level?
    - Check out my full course "React Testing Mastery": bit.ly/3IBuILB
    - Subscribe for more videos like this: goo.gl/6PYaGF
    ✋ Stay connected:
    - Twitter: / moshhamedani
    - Facebook: / programmingwithmosh
    - Instagram: / codewithmosh.official
    - LinkedIn: / codewithmosh
    👉 Related tutorials:
    - JavaScript Unit Testing Tutorial: • JavaScript Unit Testin...
    - React Tutorial for Beginners: • React Tutorial for Beg...
    - TypeScript Tutorial for Beginners: • TypeScript Tutorial fo...
    👉 Full courses:
    - React Testing Mastery: codewithmosh.com/p/react-test...
    - React 18 for Beginners: codewithmosh.com/p/ultimate-r...
    - React 18- Intermediate Topics: codewithmosh.com/p/ultimate-r...
    - Mastering JavaScript Unit Testing: codewithmosh.com/p/mastering-...
    - The Ultimate TypeScript Course: codewithmosh.com/p/the-ultima...
    📖 TABLE OF CONTENT
    0:00:00 - Introduction
    0:01:21 - Prerequisites
    0:03:00 - Course Structure
    0:04:46 - How to Take this Course
    0:06:37 - Setting Up the Development Environment
    0:07:36 - Setting Up the Starter Project
    0:13:31 - Setting Up Vitest
    0:17:19 - Setting Up React Testing Library
    0:20:24 - Testing React Components
    0:21:15 - What to Test
    0:24:31 - Testing Rendering
    0:33:12 - Simplifying Test Setup
    0:36:16 - Exercise: Testing UserAccount
    0:41:52 - Announcement
    0:42:41 - Testing Lists
    0:48:46 - Exercise: Testing ProductImageGallery
    0:53:08 - Testing User Interactions
    01:02:04 - Exercise: Testing ExpandableText
    01:13:17 - Simplifying Tests
    #react #reactjs #testing

КОМЕНТАРІ • 136

  • @programmingwithmosh
    @programmingwithmosh  3 місяці тому +5

    - Want to learn more? Get the full course: codewithmosh.com/p/react-testing-mastery
    - Subscribe for more videos like this: goo.gl/6PYaGF

    • @vinitgirde
      @vinitgirde 3 місяці тому +3

      Not able to buy this course from above link . The page shows " This product is not available. Contact the school owner for more information." Please check .

    • @user-yz2mv8kn4x
      @user-yz2mv8kn4x 3 місяці тому

      same here@@vinitgirde

    • @HeyMr.OO7
      @HeyMr.OO7 3 місяці тому

      Chutiya course 😂😂😂

    • @JayCraft-mf2pt
      @JayCraft-mf2pt 3 місяці тому

      @programmingwithmosh please I couldn't download the Python & SQL cheat sheets. It's given a response of the security certificate expiring 165days ago. It advised not to go further as it's unsafe for my PII in my device. Please help

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому

      @@JayCraft-mf2pt I’m sorry to hear that! I took a note and will fix it tomorrow morning.

  • @invertedcoder
    @invertedcoder 3 місяці тому +17

    Mosh has got some insane skilles

  • @bcb3548
    @bcb3548 3 місяці тому +6

    Was looking up Vitest yesterday and Mosh drops this! Couldn't have been more auspicious.

  • @tonishant
    @tonishant 3 місяці тому +9

    One of the best tutor on YT.

  • @user-ks7py9ob9h
    @user-ks7py9ob9h 3 місяці тому +2

    The method of instruction is fantastic. Many thanks, Mosh 💌

  • @SaadxBaig
    @SaadxBaig 3 місяці тому +1

    Can’t wait to learn more about testing in react Mosh! The best teacher out there

  • @pandalife1313
    @pandalife1313 3 місяці тому

    This is the first video that explains everything about React Testing indetails and in a clear format. Thank you so much Mosh

  • @davidomiunu782
    @davidomiunu782 3 місяці тому +1

    Perfect timing. I’m excited about this video

  • @mohammadyusuf4371
    @mohammadyusuf4371 Місяць тому

    I am learning a lot from your videos and glad to have the membership 🙏 Thanks Mosh for being there!

  • @ky8designs
    @ky8designs 3 місяці тому +1

    Thank you Mosh for your efforts, I loved programming because of you.

  • @adamadiengba6928
    @adamadiengba6928 3 місяці тому +4

    Good job again Mosh. So, Modern Angular testing course would be appreciated.

  • @AnuragArwalkar
    @AnuragArwalkar 3 місяці тому

    Thanks a lot, Mosh, for your detailed programming videos

  • @fpigeonjr
    @fpigeonjr 21 день тому

    🤩Thanks Mosh for this course, love the polish and teaching style. Running thru this now.

  • @catalinionescu5658
    @catalinionescu5658 2 місяці тому

    Best course on react testing on YT. Thanks Mosh!

  • @juanmacias5922
    @juanmacias5922 3 місяці тому

    This was such a great tutorial! I've been wondering how TDD would work with UI, and this helped me understand how I could go about it, thanks!

  • @JIPP71984
    @JIPP71984 3 місяці тому +1

    Looking forward to completing this one
    Would love a spring boot course from you one day.

  • @jlimsy1
    @jlimsy1 Місяць тому +1

    The only course on React testing that I managed to complete without hitting unsolvable bugs left and right

  • @KzCorp-jt4te
    @KzCorp-jt4te 2 місяці тому

    Wow... this tutorial was amazing. One of the best on testing that I have seen.

  • @JOJO_THE_PROGRAMMER
    @JOJO_THE_PROGRAMMER 3 місяці тому

    Awesome course Mosh

  • @nurudeenhamzah5011
    @nurudeenhamzah5011 3 місяці тому

    Quality videos from Mosh, expect no less ❤

  • @maicaotri3668
    @maicaotri3668 28 днів тому

    Thanks a lot, good for understanding

  • @DigitalCreator5
    @DigitalCreator5 3 місяці тому +1

    Hurray 🎉 thanks mosh 😂

  • @roelaneroy2588
    @roelaneroy2588 3 місяці тому

    Thank you, Mosh! for this great tutorial. For sure, the full course on this is third course I'm going to buy from you. 🏆🏆

  • @SkillsMatterTouhidSayed
    @SkillsMatterTouhidSayed 3 місяці тому +3

    Hi mosh,
    Is any chances to have a Springboot course?

  • @exposetheworldfacts
    @exposetheworldfacts 3 місяці тому

    ❤❤My dear Mosh I am too much inspired by your methodology of teaching. I love it!
    Please make a complete tutorial on Flutter and also on Django framework

  • @rohansachdeva627
    @rohansachdeva627 22 дні тому

    Most underrated skill that only professional devs can appreciate. Thanks Mosh :)

  • @baltaza
    @baltaza 11 днів тому

    Great resource!

  • @Noor-e-islam587
    @Noor-e-islam587 3 місяці тому

    You are unique sir

  • @deepakjha4138
    @deepakjha4138 3 місяці тому

    great tutorial

  • @shakyadissanayaka
    @shakyadissanayaka 3 місяці тому

    Thank you very much sir

  • @UniqueEdit243
    @UniqueEdit243 3 місяці тому

    Our legend comes back again. ❤❤

  • @fireheart__7
    @fireheart__7 3 місяці тому

    Awesome!! ❤

  • @jessewakukha1196
    @jessewakukha1196 3 місяці тому +1

    Nice one mosh...from Nairobi kenya

    • @madinafest
      @madinafest 3 місяці тому

      Also following from Nairobi, Kenya. 🔥⚡💥

  • @cameronerasmus633
    @cameronerasmus633 2 місяці тому

    Hi Mosh! First off - I just want to thank you for your incredible lessons. You have a gift, very few people can explain anything code as well as you do. I'm a high school science teacher myself, so I understand how much work it takes. I came across your courses for the first time in early 2022. A few dozen hours of Mosh that lead to a few dozen projects, that finally lead to my first job as an engineer! You sparked a passion inside of me that I never new I had - I will be forever grateful. Thank you, Mosh.
    Would you ever consider doing a course on microservices? Maybe using the MERN stack. I would buy that course a dozen times over and recommend it to every human being I know - coder or otherwise!

    • @programmingwithmosh
      @programmingwithmosh  2 місяці тому

      Thank you for your kind words. Microservices is one of those overrated technologies I’m reluctant to teach as it educates bad habits. The hype is already over and more and more people are getting back to monolith.

  • @ko9
    @ko9 3 місяці тому +11

    Will this be just as applicable for a NextJS project, or are there significant differences in testing NextJS apps?

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому +4

      For the most part, yes! The knowledge you learn in the course can be applied to a Next.js project because you’re still dealing with React components. But routing in Next.js is different from what we’ve covered in the course.

    • @dedstronk
      @dedstronk 3 місяці тому

      @@programmingwithmoshwhy not also add section for nextjs since you also teached or make a course for testing nextjs application since its rare to find some?

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому +12

      My goal is to teach you to fish rather than feed you fish. With the materials I put together in this course, you won’t need me in the future and can figure out the rest on your own.

  • @valenciawalker6498
    @valenciawalker6498 3 місяці тому

    Thank you

  • @mohaimenkhalid3844
    @mohaimenkhalid3844 8 днів тому

    you are just amazing..

  • @orisfinatech705
    @orisfinatech705 Місяць тому

    Thanks for this amazing course. I would love to ask, as a beginner should I focus on writing test cases before code or write my code and then write test cases to see if my code passes those test cases

  • @mutabazi250-hj1jb
    @mutabazi250-hj1jb 3 місяці тому

    Cool👍keep it up bro

  • @ibrahimolammy471
    @ibrahimolammy471 2 місяці тому

    Thanks Mosh for these tutorials, you're indeed a great tutor. I'd like to know if you have the intention of creating a PHP course.

  • @cywiz
    @cywiz 3 місяці тому +4

    Please update react native and nodejs course..... Or please let us know if backend does not have any breaking changes...
    And......lots of 💕 love, for being there for every self taught programmers

    • @webmobile21
      @webmobile21 2 місяці тому

      updated react native course that includes testing title as well

  • @user-ll4qy6cg9i
    @user-ll4qy6cg9i 3 місяці тому

    Should we test hooks and and context alone or only in the components where they are used?

  • @mehdiskan
    @mehdiskan 3 місяці тому

    😍Eyval Mosh, In Course Awliee;

  • @efraim-andrade
    @efraim-andrade Місяць тому

    Great video 👏, what vscode theme is this ?

  • @josephajibodu2377
    @josephajibodu2377 3 місяці тому

    The Legend 🚀

  • @MohammadMansourBone
    @MohammadMansourBone 3 місяці тому

    Finally 🙌

  • @codeofmohit
    @codeofmohit 25 днів тому

    Hey mosh, nice tute, btw, but in my components in describe block, only 1 it block/test runs at a time, if i have 2 valid tests, at a time only 1 will run, multiple tests are not running, i mean they can run but will fail only 1 test at a time passes, the comonent uses context based dark/light theme switching ? any suggestions here, what m doing wrong ?

  • @mylesgideonprospero
    @mylesgideonprospero 3 місяці тому

    I am trying to comprehend how do people write test modules without knowing the production code beforehand when they do Test Driven Development approach
    Nonetheless, thank you for providing this and the timing is crazy since I only started looking into testing recently. Out of thousands of tutorial videos, I will always pick your videos.
    I appreciate your well-thought out content as always ~

  • @SteveNewman1955
    @SteveNewman1955 3 місяці тому +1

    hi mosh ,
    is there any chance to have a series on spring and microservices
    i really love the way you teaching
    and i cant understand the other instructors ...
    recently i finished your java series and i really love it
    l'm looking for job in backend development
    really really appreciate that if you help me ....
    thanks ❤

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому

      Thank you very much! I have spring on my list but I’m not sure where I’ll be work on it as there are many other topics that students have requested more.

  • @dakshkumar4032
    @dakshkumar4032 3 місяці тому

    amazing

  • @user-ll4qy6cg9i
    @user-ll4qy6cg9i 2 місяці тому

    Hi Mosh would it be possible you could show how you would test your ErrorPage in this project? I have the same structure on my ErrorPage and i got this error, Error: useRouteError must be used within a data router, I guess it is since i use createBrowserRouter and i'm not sure how to mock it.

  • @Nyanda_Jr
    @Nyanda_Jr 3 місяці тому

    Hello Sir. Nice being here

  • @mutabazi250-hj1jb
    @mutabazi250-hj1jb 3 місяці тому

    Well be back Mr Mosh, after sometime

  • @kamauwaweru4991
    @kamauwaweru4991 3 місяці тому

    i love it

  • @natalias.2267
    @natalias.2267 3 місяці тому

    Hi, do you accept cards from any country? I have problems with payment

  • @bleir82
    @bleir82 26 днів тому

    Hi! I want to try this but during running npm start I have error "TypeError: this.spawn is not a function" this I think is from concurrently :( I have tried on node 20.10 and newest one 22.1

  • @Cloudscloud7300
    @Cloudscloud7300 2 місяці тому

    Thank you, Can we have video for Building Large language model for beginners ?

  • @HeyMr.OO7
    @HeyMr.OO7 3 місяці тому +1

    Hey Mosh, Should I buy your Rect 16 course instead of 18 ? Coz that's lot cheaper for me at this beginner stage . I just wanna learn the react ⏳🤔🤔

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому

      I wouldn’t recommend that as so much has changed since then!

  • @AnonymousCoder7
    @AnonymousCoder7 3 місяці тому +3

    Hey Mosh Any plans on system design course or Machine learning course .. these topics would be great to make a course on... Thoughts ??!

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому +2

      I was thinking of it for a while but got distracted with a million things! Thanks for the reminder. I’ll see what I can do, but no promises! ;)

    • @HeyMr.OO7
      @HeyMr.OO7 3 місяці тому +3

      @@programmingwithmosh I really believe you could do a great course on Cloud computing, ML, System Design or may be iOS development.
      Pls give a small reply if you read this 🙌🏻

    • @AnonymousCoder7
      @AnonymousCoder7 3 місяці тому +3

      ​@@programmingwithmoshyeahh mosh .. I think he is correct... We're friends
      Pls consider above topics if you can manage .. wud be great..
      pls like/reply if you read this 💙

    • @RKSharma019
      @RKSharma019 3 місяці тому +3

      ​@@programmingwithmosh Hey Mosh these are really great courses ... will you pls. Consider ??! 👍🏻

  • @Followme841
    @Followme841 3 місяці тому +1

    Mosh, can you please add ( the dom ) in your java script course with some best practice exercises and also ( async await ) please❤

  • @jayanthkumar6859
    @jayanthkumar6859 3 місяці тому

    mosh please make a course on go and rust

  • @devoni_com
    @devoni_com 3 місяці тому

    Hello sir, I want to learn and participate in your courses, but I have a question: Can a person who does not know anything about programming follow this course that you will offer? Will I be ready for the job market and have sufficient experience?

  • @ar-swe
    @ar-swe 3 місяці тому +1

    please make ts node backend series mosh

  • @user-cn9oo5uw6f
    @user-cn9oo5uw6f 3 місяці тому

    Will you put this course on Udemy ? My company provided me a udemy business acct n I would like to take advantage of tht

  • @webmobile21
    @webmobile21 2 місяці тому

    is vitest applicable for react native

  • @mehakgrover2174
    @mehakgrover2174 3 місяці тому

    Mosh please make tutorial on flutter

  • @sukreth1413
    @sukreth1413 3 місяці тому

    Hi can you make video about how to print first n perfect number in python I searched in internet and chatgpt it has no correct solution only printing first 8 perfect numbers

  • @thaifred
    @thaifred 3 місяці тому

    How could i access my base_url from my config.json file?

  • @ShakkeerTheCoder
    @ShakkeerTheCoder 2 місяці тому +1

    Mosh, we need tutorial on GraphQL

  • @rakeshmaurya5148
    @rakeshmaurya5148 3 місяці тому

    Sir i am fig fan of you. I want to purchase your pro course.

  • @moewai6256
    @moewai6256 2 місяці тому

    Why we need so many library to use? react-testing library, jsdom and jest-dom

  • @Ninjacode554
    @Ninjacode554 2 місяці тому

    My teacher, makes a testing course with jest and react native testing library, please 🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @raghavenderkuppireddy7158
    @raghavenderkuppireddy7158 3 місяці тому

    ❤❤❤❤❤

  • @minimalsforlife740
    @minimalsforlife740 3 місяці тому

    ❤❤❤

  • @azharqureshi9814
    @azharqureshi9814 2 місяці тому

    Can we download the course after purchasing from mosh site ?
    Anyone has experienced this?

  • @rashidkhanjamali4358
    @rashidkhanjamali4358 3 місяці тому

    Mosh please Upload zero to mastery Full Stack development

  • @burhaanhassan5498
    @burhaanhassan5498 3 місяці тому

    I am more interested to see how you implemented the frontend, that can teach us a lot also it summarise the most important skills of react js. Please if you can share with us. sure, we can Colone the repo and see how it's build but Wanna see you doing it

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому

      The project has a GitHub repo. I explained that at the beginning. Feel free to clone the project and study it. If you learn better by videos, I've covered all the tools and techniques used in this project (except auth) in my React Intermediate course: codewithmosh.com/p/ultimate-react-part2

  • @ed-vm1gb
    @ed-vm1gb 3 місяці тому

    vscode theme?

  • @arikmosfor4907
    @arikmosfor4907 3 місяці тому

    what theme are you using?

  • @user-fb1vi6pn3w
    @user-fb1vi6pn3w 3 місяці тому

    Hello mosh we need update on your .net course

  • @SANTOSHYADAV-fx6fu
    @SANTOSHYADAV-fx6fu Місяць тому

    is this course is on Udemy ?

  • @hzakaria5338
    @hzakaria5338 3 місяці тому

    Mosh why you dont give online courses for react native mobile app development ,, there are a lot of complications just to implement the environment 😞

  • @LemonGaming43021
    @LemonGaming43021 3 місяці тому

    I want you to update your node js series course because your node course is out of date.

  • @sahandmahdavi6134
    @sahandmahdavi6134 3 місяці тому

    Can be also used for React Native?

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому +1

      Yes! Most of the techniques and best practices you learn in the course can be applied to React Native projects. You just need to install React Native Testing Library, instead of React Testing Library.

    • @sahandmahdavi6134
      @sahandmahdavi6134 3 місяці тому

      @@programmingwithmosh Thanks Mosh!

    • @sahandmahdavi6134
      @sahandmahdavi6134 3 місяці тому

      @@programmingwithmosh That's amazing, I was watching the UA-cam 1H introduction and it seemed to be practical.
      On the other side I think if you can give us a course of Vue.js, would be helpful TBH.

  • @durgaprasad-vm4mh
    @durgaprasad-vm4mh 3 місяці тому

    I am unable to buy this course. Encountering fallowing error: "This product is not available. Contact the school owner for more information."

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому

      Sorry! That was a temporary issue. It's fixed now. Try again and let me know if it's still happening on your end.

  • @Astrelune
    @Astrelune 6 днів тому

    20:21

  • @dimarialara5752
    @dimarialara5752 3 місяці тому

    Do php please🥺

  • @oussemabouyahia474
    @oussemabouyahia474 Місяць тому

    how many times , did you repeat that you have 20 years experience in software

  • @doict7788
    @doict7788 3 місяці тому

    Going one course to another....

  • @christopheradolphe
    @christopheradolphe 3 місяці тому

    That's exactly the course I was looking for. I bought it because I really like your teaching style and I know it's worth every dollar. I have never been disappointed with any of the courses, so thank you @programmingwithmosh for creating such great content.

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому +1

      Thank you so much for your support and lovely words! 🙏

    • @christopheradolphe
      @christopheradolphe 3 місяці тому

      You are welcome@@programmingwithmosh My goal this year is to improve my React skills and I'm sure that by the end of this course that goal will be achieved.

  • @artsycoder533
    @artsycoder533 2 місяці тому

    Nice tutorial! Im following along and im getting a failing test when testing for the absence of the edit button if the user is not an admin.
    it("should not render edit button if user is not admin", () => {
    const user: User = { id: 1, name: "My Name" };
    render();
    const button = screen.queryByRole("button");
    expect(button).not.toBeInTheDocument();
    });
    its still finding the edit button:
    expected document not to contain element, found
    Edit
    instead
    ive added console logs in the UserAccount component to see the value of isAdmin as well as if the button is being rendered and both are logging false:
    console.log("user.isAdmin:", user.isAdmin);
    console.log("Button rendered:", user.isAdmin && Edit);
    when i run screen.debug() i do see that the edit button is in fact not there in the 3rd test case, i just do not understand why the test is failing?
    User Profile

    Name:

    My Name

    has anyone ran into this?

  • @devbyali
    @devbyali 3 місяці тому +1

    We need a spring boot course

  • @thaifred
    @thaifred 3 місяці тому

    Hi Mosh, i discovered when i test with react query this import in the testfile fails import { QueryClient, QueryClientProvider } from '@tanstack/react-query'. but this work import { QueryClient, QueryClientProvider } from 'react-query', do you have any ideas why? I using the latest version "@tanstack/react-query": "^5.24.2". And how come u use version 3? Thanks in advance 😁

    • @programmingwithmosh
      @programmingwithmosh  3 місяці тому +1

      If you’re talking about the project I’ve used in the course, the correct installed package is react-query. But I think they renamed it to @tanstack/react-query in a newer version. Check the package.json to see what is installed.

    • @thaifred
      @thaifred 3 місяці тому

      Solved it, since i installed "@tanstack/react-query": "^5.24.2". it didn't update react-query since i guess that version where not part of the tanstack, so by unistall react query it worked. Leave it here as ref if somebody else get the same issue, thanks for an great tutorial i taking the full course.