diff --git a/src/queries/__tests__/predicate.test.tsx b/src/queries/__tests__/predicate.test.tsx new file mode 100644 index 000000000..764c89aad --- /dev/null +++ b/src/queries/__tests__/predicate.test.tsx @@ -0,0 +1,89 @@ +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) => (element: ReactTestInstance) => { + return element.props.testID === testID; + }; + + const textInputPredicate = function matchTextInput( + element: ReactTestInstance + ) { + // @ts-expect-error - ReatTestInstance type is missing host element typing + return element.type === 'TextInput'; + }; + + const { getByPredicate, getAllByPredicate } = render( + + Text + + +