getAllComponentsByTestId<T extends Component> function

List<T> getAllComponentsByTestId<T extends Component>(
  1. dynamic root,
  2. String value,
  3. {String key = defaultTestIdKey}
)

Similar to getAllByTestId, but filters out results that aren't Dart components.

This is useful when the Dart component you're targeting forwards props.

For example, given a usage of a component that forwards its props to the rendered DOM: // Dart Input (ForwardsProps() ..addTestId('foo') )() // HTML output '

'

// This returns // `Instance of 'JsObject'`, (the JS component) // `Element:<div class="forwards-props" data-test-id="foo" />`, // getAllByTestId(root, 'foo')

// This returns `<Instance of 'ForwardsPropsComponent'>` getAllComponentsByTestId(root, 'foo')

Implementation

List<T> getAllComponentsByTestId<T extends react.Component>(dynamic root, String value, {String key = defaultTestIdKey}) =>
    getAllByTestId(root, value, key: key)
        .map((element) => getDartComponent<T>(element)) // ignore: unnecessary_lambdas
        .whereNotNull()
        .toList();