From d55ea0b0b45616b498a782e37241a46ebb469cea Mon Sep 17 00:00:00 2001 From: Alvaro Catalina Date: Mon, 7 Sep 2020 21:39:16 +0100 Subject: [PATCH] feat: RegExp support for *ByTestId queries (#535) * getAllByTestId supports a regex matcher * update typings * docs: update * refactor types * refactor. remove unnecessary try/catch * refactor test assertions --- src/__tests__/getByApi.test.js | 15 +++++++++++++++ src/helpers/findByAPI.js | 4 ++-- src/helpers/getByAPI.js | 12 +++++++++--- src/helpers/queryByAPI.js | 4 ++-- typings/__tests__/index.test.tsx | 8 ++++++-- typings/index.d.ts | 12 ++++++------ website/docs/Queries.md | 2 +- 7 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/__tests__/getByApi.test.js b/src/__tests__/getByApi.test.js index db66b1c6..a2b2637d 100644 --- a/src/__tests__/getByApi.test.js +++ b/src/__tests__/getByApi.test.js @@ -35,3 +35,18 @@ test('getByTestId returns only native elements', () => { 'No instances found with testID: myComponent' ); }); + +test('supports a regex matcher', () => { + const { getByTestId, getAllByTestId } = render( + + Text + + +