:wave: Hi, what is the best way to assert that an ...
# compose
d
👋 Hi, what is the best way to assert that an item does not exist on a lazy container? On a list of 1000 items, I tried using something like:
Copy code
composeRule.onNode(hasText("Item - 500")).assertDoesNotExist()
and it still passes even though
Item - 500
does exist, just not rendered. Is the only way to verify this is to try to scroll to that item and catch the failure?
Copy code
fun assertItemDoesNotExistInLazyList(matcher) {
  try {
    scrollTo(matcher)
    throw AssertionError(..)
  } catch (e: AssertionError) {
    // item actually does not exist on the lazy list
  }
}
I'm curious if there is a more idiomatic way to do this. Thanks!
e
That's usually how I approach this (but with
performScrollToNode
)
👍 1
d
Cool! I myself couldn't find a better way searching around.
t
sorry it's irrelevent to your question but don't you think loading 1000 items in the memory will make the app slow ? unless you make it as a pagination ?
d
it depends on apps current memory usage, where it's being loaded (main thread vs bg thread), and how its being shown (lazy vs non-lazy), and whether it's being disposed off when it's no longer needed (leaky?), and probably other parameters. I imagine it starts becoming a potential issue maybe around 100,000 items depending on each item's memory footprint. 🤷