Skip to player
Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Comments
Bookmark
Share
Add to Playlist
Report
How to test Next.js link component using Jest
InterTuts
Follow
8/12/2024
This video shows how to test the Next.js link component using Jest. I'm verifying if the link contains correct url and the text with next-intl is rendered correctly.
Category
🦄
Creativity
Transcript
Display full video transcript
00:00
In this video, I wish to show an easy way to verify if a link is rendered correctly in Next.js
00:14
For this purpose, I will use Jest
00:20
To create the link, I'm using the Next.Link component
00:30
And for the text, I'm using Next.InternationalLibrary
00:39
In my test file, I will use await to load the component
00:57
Where I have an asynchronous function to load the screens
01:10
Then, I will render the component
01:16
And will look for the dashboard screen in the link text
01:31
Here I will verify if the dashboard text exists
01:38
And then will verify if the URL is correct
01:46
I have explained even in my previous video
01:51
That I have a setup file in the Jest configuration file
01:59
Where I have global mocks and one is for the Next.InternationalLibrary
02:08
I have created it to simulate the getTranslations function
02:17
Which is used to render the prints in JSON files
02:25
This is useful to render the text during the tests
02:34
Now, I will run a test
02:39
The test is passed correctly
Recommended
2:28
|
Up next
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