Skip to content Skip to sidebar Skip to footer

Detox Only Testing Splash Screen

I am running detox on my React-Native project and can only test the splash screen. The splash screen goes to a Login Screen but the detox code will not allow me to test this elemen

Solution 1:

It takes time items to render on the screen. You can use the waitFor property that detox provides.

In most cases, tests should be automatically synchronized with the app. When synchronization doesn't work, you have a fail-safe by using waitFor.

You can read more about using waitFor in the documentation.

NOTE: Every waitFor call must set a timeout using withTimeout(). Calling waitFor without setting a timeout will do nothing.

NOTE: waitFor will not throw when reaching timeout, instead it will just continue to the next line. To make sure your tests work as you expect them to add expect() at the following line.

So based on the example in the documentation you should update your test to be

it('should show login screen', async () => {
  await expect(element(by.id('splash'))).toBeVisible()
  await waitFor(element(by.id('login'))).toBeVisible().withTimeout(2000);
  await expect(element(by.id('login'))).toBeVisible()
});

Post a Comment for "Detox Only Testing Splash Screen"