From 8473762c27e15551e5d0a433b9b7d0d1a9b5f9fe Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Thu, 5 May 2022 11:50:50 +0200 Subject: [PATCH 1/6] feat: predicate query POC implementation --- src/queries/__tests__/predicate.test.tsx | 36 ++++++++++++++ src/queries/predicate.ts | 60 ++++++++++++++++++++++++ src/within.ts | 2 + 3 files changed, 98 insertions(+) create mode 100644 src/queries/__tests__/predicate.test.tsx create mode 100644 src/queries/predicate.ts diff --git a/src/queries/__tests__/predicate.test.tsx b/src/queries/__tests__/predicate.test.tsx new file mode 100644 index 000000000..8cb81ab5a --- /dev/null +++ b/src/queries/__tests__/predicate.test.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { View, Text, TextInput, Button } from 'react-native'; +import { ReactTestInstance } from 'react-test-renderer'; +import { render } from '../..'; + +test('getByPredicate returns only native elements', () => { + const testIdPredicate = (testID: string) => (node: ReactTestInstance) => { + return node.props.testID === testID; + }; + + const { getByPredicate, getAllByPredicate } = render( + + Text + + +