Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View component don't work as expected with testID with newArch #49857

Open
ulricden opened this issue Mar 6, 2025 · 6 comments
Open

View component don't work as expected with testID with newArch #49857

ulricden opened this issue Mar 6, 2025 · 6 comments
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@ulricden
Copy link

ulricden commented Mar 6, 2025

Description

when I add Testid to a View, the behavior of the ViewGroup with newArch enabled is strange.
All the Viewgroups stay in the DOM, but they become separate from their children.

on appium inspector (do exactly the same on android studio) :

- without newArch :
Image

- with newArch enabled :

Image

Steps to reproduce

I created a new project with Expo, following the instructions from the React Native tutorial. After that, I modified the home screen.

npx create-expo-app@latest
// app/(tabs)/index.tsx
import React from "react";
import { Text, View } from "react-native";

export default function HomeScreen() {
  return (
    <View>
      <View testID={"container"} style={{ margin: 10 }}>
        <View testID={"title"} style={{ margin: 10 }}>
          <Text>{"this is a title"}</Text>
        </View>
      </View>
    </View>
  );
}

React Native Version

0.76.7 same on 0.77.1

Affected Platforms

Runtime - Android

Areas

Fabric - The New Renderer

Output of npx @react-native-community/cli info

System:
  OS: Linux 6.11 Ubuntu 24.10 24.10 (Oracular Oriole)
  CPU: (16) x64 AMD Ryzen 7 PRO 6850U with Radeon Graphics
  Memory: 18.19 GB / 30.13 GB
  Shell:
    version: 5.2.32
    path: /bin/bash
Binaries:
  Node:
    version: 20.17.0
    path: /run/user/1000/fnm_multishells/11758_1741251328545/bin/node
  Yarn:
    version: 1.22.22
    path: /run/user/1000/fnm_multishells/11758_1741251328545/bin/yarn
  npm:
    version: 11.1.0
    path: /run/user/1000/fnm_multishells/11758_1741251328545/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "30"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-27 | Google Play Intel x86 Atom
      - android-30 | Intel x86_64 Atom
      - android-30 | Google APIs Intel x86 Atom
      - android-30 | Google Play Intel x86 Atom
      - android-35 | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: AI-242.23339.11.2421.12483815
Languages:
  Java:
    version: 21.0.6
    path: /usr/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.7
    wanted: 0.76.7
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

no stacktrace to link

Reproducer

https://github.com/ulricden/ViewGroupIssue

Screenshots and Videos

No response

@ulricden ulricden added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Mar 6, 2025
@react-native-bot react-native-bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Mar 6, 2025
@react-native-bot
Copy link
Collaborator

Warning

Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

@cipolleschi
Copy link
Contributor

@ulricden Thanks for opening the issue.
What happens on the New Architecture if you remove the TestID? I expect the components to disappear due to View Flattening. Is that the case?

I will surface the issue to people that have more Android knowledge.

@ulricden
Copy link
Author

ulricden commented Mar 6, 2025

Yes, When I remove the testID, the view disappears as expected.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Mar 6, 2025
@cipolleschi
Copy link
Contributor

I was asking about that internally, and it looks like that the change in behavior is expected. The testID alone does not defines a stacking context, therefore the views are siblings, in the new architecture.

What's your use case? Are you trying to grab the view by its testID and then inspect whether it has some specific child? Or you open an issue just because you observed the difference?

@ulricden
Copy link
Author

I was asking about that internally, and it looks like that the change in behavior is expected. The testID alone does not defines a stacking context, therefore the views are siblings, in the new architecture.

Okay, but why does it create an empty ViewGroup over all children instead of removing it along with its testID?

For my use case, I use the testID in E2E tests and need to inspect whether it contains a specific child.

@ulricden
Copy link
Author

for information, it's do the same with accessibilityLabel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

3 participants