From d3e008b9eb4a847702692f272346f2e0ef3adae1 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sun, 3 Oct 2021 11:07:43 +0200 Subject: [PATCH 1/2] Expected behavior for `within` and custom queries --- types/__tests__/type-tests.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/types/__tests__/type-tests.ts b/types/__tests__/type-tests.ts index ace17dbb..ad47e73d 100644 --- a/types/__tests__/type-tests.ts +++ b/types/__tests__/type-tests.ts @@ -117,6 +117,21 @@ export async function testQueryHelpers() { await findByAutomationId(element, ['id', 'id'], {}) await findAllByAutomationId(element, ['id', 'id']) await findByAutomationId(element, ['id', 'id']) + + const screenWithCustomQueries = within(document.body, { + ...queries, + queryByAutomationId, + getAllByAutomationId, + getByAutomationId, + findAllByAutomationId, + findByAutomationId, + }) + + screenWithCustomQueries.queryByAutomationId('id') + screenWithCustomQueries.getAllByAutomationId('id') + screenWithCustomQueries.getByAutomationId(['id', 'automationId']) + await screenWithCustomQueries.findAllByAutomationId('id', {}, {timeout: 1000}) + await screenWithCustomQueries.findByAutomationId('id', {}, {timeout: 1000}) } export function testBoundFunctions() { From 7070e6d09abcd68781eb1c53fb1cbb67ad34c983 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sun, 3 Oct 2021 11:11:33 +0200 Subject: [PATCH 2/2] fix(within): Types should list custom and base queries --- types/get-queries-for-element.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/get-queries-for-element.d.ts b/types/get-queries-for-element.d.ts index 5b5903dc..868d6d2a 100644 --- a/types/get-queries-for-element.d.ts +++ b/types/get-queries-for-element.d.ts @@ -153,6 +153,8 @@ export type BoundFunctions = Q extends typeof queries findAllByTestId( ...args: Parameters>> ): ReturnType> + } & { + [P in keyof Q]: BoundFunction } : { [P in keyof Q]: BoundFunction