Back to Browse

Deep dive in React Native Testing Library

69 views
Dec 25, 2024
50:24

I think that the main difficulty in writing and debugging tests comes from a lack of understanding of how testing tools work. Nowadays, front end testing libraries strive to provide an API that follows the paradigm, “The more your tests resemble the way your software is used, the more confidence they can give you.” This approach has led to the ability to write integration tests using a similar API than for end-to-end tests. While this provides significant benefits, it also comes with a price to pay. APIs such as waitFor or fireEvent do such a great job at abstracting implementation details that they’re very easy to use without knowing what they really do. While this is great most of the time, it gets way more complicated when things don’t work as expected. Also even if integration tests may now look alike end to end tests, they are still and will always be inherently different, especially for React Native. Being aware of what can be done and can’t be done in integrations tests and in what it differs from a production like environment is fundamental. I’ve been a contributor and then a maintainer of React Native Testing Library (RNTL) for about a year now. Through this experience, I have gained a deep understanding of the library’s internal behavior. What I’ve found is that this knowledge is extremely useful in my job as a Tech Lead but also that the source code of RNTL is rather accessible and worth looking at. That’s why I want to share what I’ve learned and encourage others to look at what hides beneath RNTL’s public API. During this talk, we will cover the following topics: - What it means to test a mobile app in a node environment - The objects that we render and manipulate in integration tests - How the main APIs from RNTL work: render, fireEvent, queries, waitFor, act, … We will explore these topics through live coding by reading the source code of RNTL and writing tests that serve as examples. By the end of this talk you’ll have an overview of what I think are the most important things to know about how RNTL works and also have become more familiar with the library’s source code so that it is less intimidating. By Pierre Zimmermann

Download

0 formats

No download links available.

Deep dive in React Native Testing Library | NatokHD