0

I am new to write test cases using detox for React Native app. I already wrote few test cases and working as expected.

Is it possible to add condition in test case like using if-else.

Sujit
  • 610
  • 7
  • 26

1 Answers1

4

You can do that using a try catch block. An example is:

try {
   await expect(element(by.text(user))).toExist();
} catch (e) {
   const userField = by.id(Account.LoginView.userNameInput);
   await element(userField).tap();
   await element(userField).replaceText(user);
}
Tardis
  • 71
  • 4