• 3 months ago
next-intl is a powerful library specifically designed for handling internationalization (i18n) within Next.js applications. It offers a comprehensive solution for managing translations, date and number formatting, and internationalized routing.

This video shows how to test Next.js components where the strings are added with the next‑intl library.
Transcript
00:00In this video, I will show how to render strings from Next.js components using REST.
00:14The strings are added using the Next.js International Library.
00:22To verify if the string is rendered correctly, I have created a test file where I'm using
00:45Jest to load the page component, render it and verify if the string exists.
01:02Moreover, in my Jest configuration file, I have set up a file where I will store all the global mocks.
01:24My first mock is for Next.js International Library.
01:32I need this mock to simulate the getTranslation function, which is used to get the strings from my JSON file.
01:54I need to verify if this string is rendered correctly.
02:04And it works as expected.

Recommended