Menu

1 / 3

The Cypress i18n Mistake: Testing Words Instead of Meaning - i18next is your partner

DEV Community·Sebastian Clavijo Suero·6 months ago
#3FuWFseL
#act#let#where#i18next#enter
Reading 0:00
15s threshold

A Better Way to Test Multilanguage Apps in Cypress

Table of contents

ACT 1: EXPOSITION

ACT 2: CONFRONTATION

The Problem With Copy-Pasting Translations

What if Cypress Could Be Polyglot?

Let Me Introduce You to i18next, If You Haven’t Met It Yet

Where Should the Translations Live?

Creating Small cy.initI18n() and cy.t() Commands

What About Fallbacks?

Running the Same Test Across Multiple Languages

A Small Example With a Language Switcher: cy.changeLanguage()

Should We Use Translated Text to Click Buttons?

When Exact Text Actually Matters

A Healthier Mental Model

Interpolation: When Translations Need Dynamic Values

Namespaces: When One Translation File Is Not Enough

i18next Can Do More Than Just Interpolation

ACT 3: RESOLUTION

ACT 1: EXPOSITION

There is a very common situation that appears when testing applications that support multiple languages.

At first, everything looks innocent.

You have an application in English, so you write something like this:

cy . contains ( ' Login ' ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.