3 Minutes With Kent

Testing with Text and Internationalization

Informações:

Sinopse

Hey folks a common question that I get about testing and especially since react testing library or testing library in general you query the DOM by giving it the text that you're looking for so you say hey I want to get a button and it's accessible name is submit. And so the comment question that I get is well that must not work for internationalized websites that's probably just for like little toy apps or internal apps or whatever where you don't have any internationalization going on, no different languages because the word submit in English is not the same as it is in French orWhatever. So yeah, this is a really common question and what my answer is. Well, just use the default language. So if you're agency in Spain and so most of your websites your default language is Spanish then write the tests using the Spanish text and you when you run the test make sure that the all the languages and stuff are accessible to the tests so that when the components are rendered and the actual default language text is ther