ReactFix
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • React
  • React Native
  • Programming
  • Object Oriented Programming

Tuesday, November 15, 2022

[FIXED] How to write effective tests for a project with i18n support?

 November 15, 2022     jestjs, next.js, react-testing-library, reactjs, unit-testing   

Issue

I am coding on a Next.js project for a while. My project has i18n support and I want to write unit tests. But I couldn't figure out how to write effective tests. Am I supposed to write unit tests for each language (English, Dutch, etc) or is there any better approach?


Solution

I guess, as I read from Kent C Dodds' article and Testing Library FAQ, in the following links you will find answers you are seeking. But before visiting the pages, here is a brief quotation from the doc:

Our first bit of advice is to try to get the default text used in your tests.

  • Testing Library FAQ: https://testing-library.com/docs/dom-testing-library/faq
  • Kent's article's section: https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#not-querying-by-text

I hope, these links will help you write your tests.



Answered By - Kalender
Answer Checked By - - Marilyn (ReactFix Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post Home

Featured Post

Is Learning React Difficult?

React is difficult to learn, no ifs and buts. React isn't inherently difficult to learn. It's a framework that's different from ...

Total Pageviews

Copyright © ReactFix