My view takes a second to load in after an event. When calling:
expect(element(by.id('my-view'))).toBeVisible()
sometimes detox finds this element and sometimes it does not. How do I tell detox to wait for the elements to appear?
You can use the waitFor
function with a timeout you define:
await waitFor(element(by.id('my-view'))).toBeVisible().withTimeout(5000)
this tells detox to wait 5000ms before failing.
See example here: https://github.com/wix/Detox/blob/master/docs/Troubleshooting.RunningTests.md#test-tries-to-find-my-component-before-its-created