Skip to content

fix(types): make third and fourth params optional for findAllBy and findBy built queries #794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions types/__tests__/type-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ async function testQueryHelpers() {
getByAutomationId(element, ['id', 'automationId'])
findAllByAutomationId(element, 'id', {}, {timeout: 1000})
findByAutomationId(element, 'id', {}, {timeout: 1000})
// test optional params too
findAllByAutomationId(element, 'id', {})
findByAutomationId(element, 'id', {})
findAllByAutomationId(element, 'id')
findByAutomationId(element, 'id')
}

async function testByRole() {
Expand Down
8 changes: 4 additions & 4 deletions types/query-helpers.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Matcher, MatcherOptions } from './matches'
import { waitForOptions } from './wait-for'
import {Matcher, MatcherOptions} from './matches'
import {waitForOptions} from './wait-for'

export interface SelectorMatcherOptions extends MatcherOptions {
selector?: string
Expand Down Expand Up @@ -39,12 +39,12 @@ export type GetAllBy<Arguments extends any[]> = QueryMethod<
HTMLElement[]
>
export type FindAllBy<Arguments extends any[]> = QueryMethod<
[Arguments[0], Arguments[1], waitForOptions],
[Arguments[0], Arguments[1]?, waitForOptions?],
Promise<HTMLElement[]>
>
export type GetBy<Arguments extends any[]> = QueryMethod<Arguments, HTMLElement>
export type FindBy<Arguments extends any[]> = QueryMethod<
[Arguments[0], Arguments[1], waitForOptions],
[Arguments[0], Arguments[1]?, waitForOptions?],
Promise<HTMLElement>
>

Expand Down