Navigate back to the homepage

React native detox with react navigation example

React Native, Detox
January 9th, 2022 · 1 min read
keep affilitate

Hello Friends 👋,

Welcome To Infinitbility! ❤️

React Native detox tutorial

When react-native navigate to another screen detox all test cases failed and now we start thinking about how to stop detox test cases execution when react-native navigate to another screen.

Today, we will see how we can stop execution for a set of times.

React navigation takes a max of 2 seconds to navigate to another screen then we will stop execution for 2 seconds when the screen is navigating.

Let start code.

following code, I have added a function waitToNavigate() and we will call when the screen is navigating.

1const waitToNavigate = duration => new Promise(resolve => setTimeout(() => resolve(), duration));
3describe('Example', () => {
4 beforeAll(async () => {
5 await device.launchApp();
6 });
7 it('should have login screen', async () => {
8 await expect(element('loginView'))).toBeVisible();
9 });
10 it('should fill login form', async () => {
11 await element('emailInput')).replaceText('[email protected]');
12 await element('passwordInput')).replaceText('1234');
13 await element('loginButton')).tap();
14 await expect(element(by.text('[email protected]'))).toBeVisible();
16 // close alert
17 await element(by.text('OK')).tap();
19 // navigate to register screen
20 await element('navigateRegister')).tap();
21 await waitToNavigate(2000);
22 });
23 it('should have register screen', async () => {
24 await expect(element('registerView'))).toBeVisible();
25 });
26 it('should fill login form', async () => {
27 await element('emailInput')).replaceText('[email protected]');
28 await element('passwordInput')).replaceText('1234');
29 await element('registerButton')).tap();
30 });

Thanks for reading…

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

melio affilitate

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide



More articles from Infinitbility

React native detox multiple typeText crash issues

React native detox, typeText method showing error when using more than two times.

January 8th, 2022 · 1 min read

How to show bullets in react native?

React native show bullet in FlatList example.

January 7th, 2022 · 1 min read
© 2020–2022 Infinitbility
Link to $ to $ to $ to $ to $ to $mailto:[email protected]