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 ' ).…