findViewWithTestKeyOrNull

Finds the first View for the component tagged with testKey in the rendered hierarchy, returning null if not found. Returns the test-keyed component's own mounted view (when it mounts as a View, e.g. a com.facebook.litho.ComponentHost); falls back to the parent host if the test-keyed component mounted as a non-View (e.g. a Drawable).

Prefer this over findViewWithTag in new tests — testKey is the supported way to identify components for test targeting, and unlike viewTag it does not couple the component to a legacy View attribute (see IgKtViewHandleDetector lint).

Requires ComponentsConfiguration.isEndToEndTestRun = true (otherwise the testKey registry is not populated). Callers typically set this in a @Before and restore in @After.