Hello Friends 👋,
Welcome To Infinitbility! ❤️
React Native detox tutorial
react-native-otp-input package not provides option to test by detox using testID but i have found some hack and i’m going to share with you guys.
Today, we will learn how we can test react-native-otp-input using detox in react native.
Lets start with code example.
1describe('register flow', () => {2 it('should able to enter otp', async () => {3 await waitFor(element(by.id('OTPInputView'))).toExist();45 await element(by.text('').withAncestor(by.id('OTPInputView'))).atIndex(0).replaceText('1');6 await element(by.text('').withAncestor(by.id('OTPInputView'))).atIndex(0).replaceText('2');7 await element(by.text('').withAncestor(by.id('OTPInputView'))).atIndex(0).replaceText('3');8 await element(by.text('').withAncestor(by.id('OTPInputView'))).atIndex(0).replaceText('4');9 });10});
In my case, i have a OTP input of 4 boxes you can also use for more then 4 boxes.
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.