Search code examples
detox

Detox: Multiple matcher count?


Is it possible to get the count of matches in multiple matches?

My case is: I have a list of ~20 items, they are server-side based, so it can change, and I want to be able to test each of them (they are toggles).


Solution

  • This is not possible currently, but will be possible in the near future, with the new getAttributes() API. This is planned for release soon.

    See the documentation here

    const multipleMatchedElements = await element(by.text('Multiple')).getAttributes();
    jestExpect(multipleMatchedElements.elements.length).toBe(5);
    jestExpect(multipleMatchedElements.elements[0].identifier).toBe('FirstElement');