This content originally appeared on Level Up Coding - Medium and was authored by Tarik
Write cross-platform end-to-end tests in Javascript
Writing tests for the code has been an essential part of programming nowadays. There are different types of software testing methodologies, such as unit tests, integration tests, and end-to-end tests. This article will cover how we can apply end-to-end testing on a simple react-native app.
We will be using Detox library which is developed and maintained by the Wix team.
The app is pretty straightforward! It allows users to like their favorite Nintendo 64 app. That said, there is actually one certain behavior to test in the app. Like functionality!
User Story
Let’s list all of what can be the user actions for this functionality:
- User opens the app.
- User sees the game card, and the game card has a like button and a total number of likes text available on it. (To compare the text after the user action)
- User presses on the like button.
- User notices that like text changed. In this case, the number of likes is increased by one.
CAVEAT: This user story can be considered an integration test in theory. Yet since the app itself is only responsible for allowing users to like their game, it is treated as end-to-end testing.
Code
We will be generating our code whilst we walk through the user stories in order. Each code block will eventually correspond to a specific user story.
- User opens the app.
2. User sees the game card, and the game card has a like button and a total number of likes text available on it. (To compare the text after the user action)
3. User presses on the like button.
4. User notices that like text changed. In this case, the number of likes is increased by one.
Full code
Demo
Let’s see everything in action.

This article has covered the preliminaries of end-to-end testing in react-native apps. For the sake of simplicity, the app itself is basic enough to demonstrate fundamental aspects of end-to-end testing. Indeed, it can be more convoluted than this one in real-life/production applications.
You can take a look at the final source code of this app using the link below.
Have a bug-free day everyone!
Level Up Coding
Thanks for being a part of our community! Before you go:
- 👏 Clap for the story and follow the author 👉
- 📰 View more content in the Level Up Coding publication
- 🔔 Follow us: Twitter | LinkedIn | Newsletter
🚀👉 Join the Level Up talent collective and find an amazing job
End-to-end testing in React Native was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Tarik
Tarik | Sciencx (2022-11-08T12:01:21+00:00) End-to-end testing in React Native. Retrieved from https://www.scien.cx/2022/11/08/end-to-end-testing-in-react-native/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.