Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Bookmark
Share
Add to Playlist
Report
How to simulate user interactions like typing in Jest's tests
InterTuts
Follow
8/19/2024
userEvent is a part of the Testing Library that provides a more advanced and flexible way to simulate user interactions like typing in JavaScript tests.
In this video I'm showing a quick way to type text in an input using userEvent.
Category
🦄
Creativity
Transcript
Display full video transcript
00:00
Testing library is a library for testing user interfaces in JavaScript applications.
00:10
It can be integrated with multiple testing frameworks.
00:16
For example, I'm using it with Rust.
00:21
In this video, I want to show how I'm simulating user interaction like typing to fill a form input in Next.js.
00:36
This can be useful, for example, to test the form validation.
00:43
For this test case, I'm using the UserEvent utility of the testing library to create a user object to trigger interactions.
01:10
Next, I'm rendering the login form with the render function and providers.
01:26
I'm using the screen function of the testing library to select the email input by placeholder.
01:56
And I'm using the user object to simulate the typing to fill this email.
02:10
Finally, in my test, I'm using the email input to verify if it has this email.
02:27
Let's run a test.
02:39
And the test is passed as expected.
02:58
And this means the value was filled.
03:09
Let's run a test.
03:14
And the test is passed as expected.
Jest
3:11
|
Up next
How to simulate user interactions like typing in Jest's tests
InterTuts
8/19/2024
3:54
How to test Formik validation using Jest and Testing Library
InterTuts
8/19/2024
5:07
How to test a Redux store using Jest
InterTuts
8/18/2024
3:22
How to test Next.js components with Redux Toolkit features using Jest
InterTuts
8/13/2024
2:58
Solution: Failed to call useTranslations because the context from NextIntlClientProvider was not found
InterTuts
8/13/2024
2:44
How to mock useRouter in Next.js version 14 using Jest
InterTuts
8/13/2024
3:36
How to test a Next.js component with dynamic route using Jest
InterTuts
8/12/2024
3:00
How to test Next.js link component using Jest
InterTuts
8/12/2024
2:29
How to test next‑intl(i18n) strings in Next.js components using Jest
InterTuts
8/12/2024
2:12
How to mock a Next.js child component using Jest
InterTuts
8/12/2024
2:33
How to test in Next.js if an image is rendered correctly using Jest
InterTuts
8/12/2024
3:52
How to test Next.js components using Jest
InterTuts
8/11/2024
2:20
How to start to use Jest with Next.js
InterTuts
8/10/2024
Recommended
2:28
Pagination in React & Next JS
InterTuts
12/20/2024
1:47
React & Node.js Social Chat: unsubscribe Facebook Pages from application's webhook
InterTuts
12/18/2024
1:22
How to use notifications alerts in React & Next JS
InterTuts
12/18/2024
3:30
React & Node.js Social Chat: how to connect Facebook Pages to receive direct messages
InterTuts
12/18/2024
1:56
How to convert a string to MongoDB ObjectId in Node.js
InterTuts
12/17/2024
2:05
How to bulk insert or update data in MongoDb with Mongoose
InterTuts
12/16/2024
1:41
How to retrieve URL's query parameters in Next.js(CSR)
InterTuts
12/15/2024
3:27
How to handle dynamic route parameters in Express.js
InterTuts
12/14/2024
1:42
How to retrieve and pass dynamic route segment between components in Next.js & React
InterTuts
12/14/2024
2:00
How to create vertical tabs in Chakra UI
InterTuts
12/14/2024
1:53
How to create a modal in Chakra UI & React
InterTuts
12/13/2024
0:49
React & Node.js Social Chat: Introduction
InterTuts
12/11/2024
3:02
How to use recipes in Chakra UI & Next.JS
InterTuts
12/11/2024
1:33
How to setup global fonts in Chakra UI & Next.JS
InterTuts
12/10/2024
2:30
How to setup global colors in Chakra UI & Next.JS
InterTuts
12/10/2024
1:54
Serializing big strings impacts deserialization performance (consider using Buffer instead and decode when needed)
InterTuts
12/9/2024
1:46
Angular & ASP.NET Core Web API Authentication: how is working registration and sign in using Google API
InterTuts
12/7/2024
4:30
Angular & ASP.NET Core Web API Authentication: how is working registration
InterTuts
12/7/2024
5:10
Angular & ASP.NET Core Web API Authentication: how is working the password reset
InterTuts
12/7/2024
2:44
Angular & ASP.NET Core Web API Authentication: how is working remember me login
InterTuts
12/7/2024
4:37
Angular & ASP.NET Core Web API Authentication: how is working login
InterTuts
12/7/2024
4:48
How to validate an email address in ASP.NET Core Web API using a custom attribute
InterTuts
11/30/2024
3:29
How to reset a reactive form in Angular 19
InterTuts
11/29/2024
3:54
How to validate Angular Material reactive form in Angular 19
InterTuts
11/27/2024
2:12
How to test .http files with REST Client
InterTuts
11/25/2024
0:51
Former Aide Claims She Was Asked to Make a ‘Hit List’ For Trump
Veuer
9/27/2023
1:08
Musk’s X Is ‘the Platform With the Largest Ratio of Misinformation or Disinformation’ Amongst All Social Media Platforms
Veuer
9/27/2023
4:50
59 companies that are changing the world: From Tesla to Chobani
Fortune
9/27/2023
0:46
3 Things to Know About Coco Gauff's Parents
People
9/23/2023
0:35
8 Things to Do in the Morning to Improve Productivity
Martha Stewart Living
9/22/2023