From 9b90d6790dbab3a9a5186ddaa49bc78746d562e5 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 13:00:18 +0200 Subject: [PATCH] fix(breaking): `getByTestId` should work only for native elements (#324) * Replaced getByTestId with fixed version * Added tests * Fixed flow-check * Updated docs * Fixed lint error * Used getByTestId in unit tests instead of queryByTestId * Updated negative checks in tests --- src/__tests__/getByApi.test.js | 37 ++++++++++++++++++++++++++++++++++ src/helpers/findByAPI.js | 4 ++-- src/helpers/getByAPI.js | 9 --------- website/docs/Queries.md | 9 ++------- 4 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 src/__tests__/getByApi.test.js diff --git a/src/__tests__/getByApi.test.js b/src/__tests__/getByApi.test.js new file mode 100644 index 00000000..db66b1c6 --- /dev/null +++ b/src/__tests__/getByApi.test.js @@ -0,0 +1,37 @@ +// @flow +import React from 'react'; +import { View, Text, TextInput, Button } from 'react-native'; +import { render } from '..'; + +const MyComponent = () => { + return My Component; +}; + +test('getByTestId returns only native elements', () => { + const { getByTestId, getAllByTestId } = render( + + Text + + +