Skip to content

feature: make all (safe) queries return host components #1132

Description

@mdjastrzebski

Describe the Feature

Currently different types of queries can return either host or composite elements:

Queries returning host components (typeof node.type === 'string'):

  • testId: host, matched by normalised testID prop
  • role: host, matched by accessibilityRole prop
  • hintText: host, matched by accessibilityHint prop
  • labelText: host, matched by accessibilityLabel prop
  • a11yState: host, matched by accessibilityState prop
  • a11yValue: host, matched by accessibilityValue prop

Queries returning composite components:

  • text: composite Text from RN, matched by normalised and flattened children prop
  • displayValue: composite TextInput from RN, matched by normalised value or defaultValue prop
  • placeholderText: composite TextInput from RN, matched by normalised placeholder prop

Queries returning either host or composite components:

  • UNSAFE_byType: either host or composite, matched by element.type which can be either string or component type
  • UNSAFE_byProps: either host or composite, matched by element.props overlap

The goal of this feature request is to make text, displayValue & placeholderText return host components. This is probably a breaking change for our users so it should warrant a major release.

Possible Implementations

Use component-tree.ts functions from #1128 to get single host child of found composite Text and TextInput components from React Native.

Related Issues

#1092

@thymikee @AugustinLF @pierrezimmermannbam wdyt?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions