Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Comments
Bookmark
Share
Add to Playlist
Report
How to test Formik validation using Jest and Testing Library
InterTuts
Follow
8/19/2024
Formik is a popular open-source library that simplifies the process of managing form state, validation, and submission.
This video shows an approach to test the Formik's form validation using Jest and Testing Library.
Category
🦄
Creativity
Transcript
Display full video transcript
00:00
In this video, I will show how I'm testing the validation for this form
00:15
using the testing library and Jest
00:21
I need to get this message in my test if the password is short
00:31
Testing library is a library for testing user interfaces in JavaScript applications
00:42
It can be integrated with multiple testing frameworks
00:47
For example, I'm using it with Jest
00:54
I want to show how I'm simulating user interaction
01:02
like typing and click to fill the form inputs in Next.js and submit the form
01:15
This is my test case
01:19
First, I'm using the UserEvent utility of the testing library
01:29
to create a user object to trigger interactions
01:37
Here I have a custom render function
01:43
which uses the same testing library
01:52
but with providers used in my application
02:00
Then, I'm using the Screen utility of the testing library
02:11
to get the email, password and login button from the login form
02:30
Next, I'm using the user object to type the email and a short password
02:46
Then, I'm verifying if the email was filled and the password
02:57
Here I'm using the click method to submit the form
03:07
Finally, I'm verifying if the error for validation exists
03:16
Let's run a test
03:26
The test is passed and this means the validation is working
Formik
3:54
|
Up next
How to test Formik validation using Jest and Testing Library
InterTuts
8/19/2024
4:00
React & Node.js Authentication: how to create login form using Chakra UI, Formik and Yup
InterTuts
7/25/2024
1:48
React & Node.js Authentication: how to install Yup and create a validation schema
InterTuts
7/25/2024
2:28
React & Node.js Authentication: how to install Formik in Next.js
InterTuts
7/20/2024
Recommended
43:11
jQuery client side form validation
SDTuts.com
9/19/2015
3:03
How to test validators and sanitizers in Express using Mocha
InterTuts
8/8/2024
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