React native exposes certain props on View
like testID that are super useful for native testing, but have following note attached to them
When RN creates the native views from the shadow nodes tree - it performs some optimizations. Views that do not actually show on screen (don't draw anything or just used in JSX to contain and layout their children) can be removed when constructing the native hierarchy. This is why they're called "layout-only" views.
As this warning suggests, a view with the testID
prop will not be removed even if it's a "layout-only" view so it will actually be there when you're performing e2e tests.
Generally speaking, rendering a lot of views can cause performance issues, but using testID
on some views won't make a noticeable difference in performance because:
testID
testID
are probably not "layout-only" views so it makes no difference if you use this prop or not regarding the optimizations.In case you do have "layout-only" views with a testID
, it would be easier to move the testID
to a more suitable view.