React Testing Library Tutorial #1 - Introduction

Net Ninja · Beginner ·🛠️ AI Tools & Apps ·4y ago

Key Takeaways

Introduces React Testing Library for beginners

Full Transcript

all right then gang so in this series you're going to learn all about react testing library and to teach you i brought on board lath harp who is an incredible teacher he's got his own youtube channel with loads of really good tutorials on typescript react aws mongodb etc he explains things really well so definitely check out his channel and subscribe the link to it is going to be down below in the video description anyway without further ado i'm going to hand you over to lathe [Music] hello everybody my name is leith harb a fellow youtuber and i will be teaching you about react testing library now before we begin i want to give a big thanks to the net ninja for reaching out to me and asking me to be a guest lecturer on his channel i'm extremely honored all right enough of that let's get in to it now before we actually start learning about react testing library and how we can utilize it to test our react application let's just go through some administrative work now in order to use react testing library in our react application well we need a react app up and running now to have a react app up and running we need to have node js installed on our local machine so if you don't have node.js installed very simple download just go to the node.js website and install the recommended foremost user's version right over here now to double check that you have it installed you can just go open up your terminal and simply do node v and if you get a version then yes you have nodejs installed on your local machine if you get something like node unknown node command unknown then you don't have node.js installed you probably made a mistake go ahead and try to re-install it so that is the first administrative work the next thing is git so we are going to be working with a pre-built react application that i have here on my github page and the reason for this is i really don't want to take the focus away from the react testing library side so i already have this pre-built react application and all we're going to be doing is focusing on testing this application now i do expect you to know a little bit of react if you are taking this crash course and the react application i have built is not very sophisticated and i believe it is very very easy to understand so i think that is all fine and dandy and i'll be going ahead and just explaining everything as i go so in order to follow along you would need to have the starter project so you need to clone this repo from my github repository and that is why you need get so if you don't have git just go to the git website and install it for your operating system similarly to check that you have git you can go ahead and just do get and then if you get this long command over here all this description then yes you have git installed if you get something like get unknown command then you don't have it installed and just go ahead and install it from here so let's actually just go ahead and clone this repo in case that you guys don't know how to do it so what i'm going to first say is that i have multiple branches here so i basically split up each lesson into multiple branches so if you ever feel stuck just check out into any one of these branches and see the code that i have written now if you want to follow along what you're going to have to do is clone this repo and check out into the starter project and let's actually go ahead and do that right now so go over here to code and then either do https or ssh if you have an ssh connection and then just click on this copy link over here and then go to your terminal i'm just going to do a quick clear and then move into whatever directory you want this folder to live in i'm just going to put it in my desktop so i'm going to cd into desktop and i'm going to do git clone and then well the link that i have that i copied from github now you can then also specify a name for the project if you want to you can call it rtl you can call it whatever if you don't specify a name then this will be the default name react testing library net ninja i'm just going to leave it like that because i actually already cloned this repo so once you execute this command you should move into that directory and you should see a folder that says react testing library ninja or whatever name that you provided so now what you can do actually is move into that directory so let me just get rid of all this so then you can move into that directory and then you need to install all of the dependencies so just do a quick npm install and then you should be able to install all of the dependencies for this react application now being that this is a react application this command might take two to three minutes to execute so i actually already did this beforehand but it might take you a little bit longer so you can go ahead and pause the video if you need to and then if you want to follow along then just check out into that starter branch so just do a get checkout and then 01 starter project so do it 01 starter project and then they'll be able now you'll be able to check out into that branch and then again i already did this i'm not going to do it again and then what you can do is an mpm start to start your application and if everything is all fine you should see this application on localhost 3000 so it is a very very simple to do application you can add a to do so go grocery shopping so let's just go grocery shopping and you can add this to do and you can see here that it updated to one task left if i added another to do like pet my cat you can see here that that also adds and you can see here now two tasks left and what i can also do is click on the to do or the task and you can see that i get this line over here and this kind of change in color and this also updates as well so this is a very simple react application but we are going to test it very thoroughly and we're going to really cover a lot of the react testing library concepts now this is a very special to do application because it really keeps you accountable in actually completing all your to-do's and how does it do that well it does that because you have a bunch of followers that are going to keep you accountable so you can basically click over here to the amount of followers and you can see all your followers now these aren't really your followers i just made an http request and i got a bunch of random users now the reason why i did this is because i want to show you how we can deal with http request with react testing library and as you can see if i refresh there's actually a period of time there's a little bit of a delay before the the users actually come in and that kind of asynchronicity can cause a lot of problems when actually testing your application and i want to show you how we can deal with it with react testing library so this is a very simple application and hopefully you got it up and running on localhost 3000 in the next sections we're going to be actually learning about react testing library and using our knowledge of react testing library to test this application so i'm super excited and i'll see you guys in the next sections

Original Description

Check out Laith's YouTube channel for more tutorials: https://www.youtube.com/channel/UCyLNhHSiEVkVwPSFKxJAfSA 🐱‍💻 Access the course files on GitHub: https://github.com/harblaith7/React-Testing-Library-Net-Ninja 🐱‍👤 Get access to extra premium courses on Net Ninja Pro - https://netninja.dev 🐱‍💻 Full React Course: https://www.youtube.com/watch?v=j942wKiXFu8&list=PL4cUxeGkcC9gZD-Tvwfod2gaISzfRiP9d 🐱‍💻 Social Links: Facebook - https://www.facebook.com/thenetninjauk Twitter - https://twitter.com/thenetninjauk Instagram - https://www.instagram.com/thenetninja/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related AI Lessons

Up next
I Asked ChatGPT to Apply to 500 Jobs (8 Interviews in 48 Hours)
Sabrina Ramonov 🍄
Watch →