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));23describe('Example', () => {4 beforeAll(async () => {5 await device.launchApp();6 });7 it('should have login screen', async () => {8 await expect(element(by.id('loginView'))).toBeVisible();9 });10 it('should fill login form', async () => {12 await element(by.id('passwordInput')).replaceText('1234');13 await element(by.id('loginButton')).tap();1516 // close alert17 await element(by.text('OK')).tap();1819 // navigate to register screen20 await element(by.id('navigateRegister')).tap();21 await waitToNavigate(2000);22 });23 it('should have register screen', async () => {24 await expect(element(by.id('registerView'))).toBeVisible();25 });26 it('should fill login form', async () => {28 await element(by.id('passwordInput')).replaceText('1234');29 await element(by.id('registerButton')).tap();30 });31});
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.