Skip to content

Commit 4d96f87

Browse files
committed
Update types and docs
1 parent b06d161 commit 4d96f87

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Unique methods, not part of `@testing-library/dom`
113113
- `findAllByDisplayValue`,
114114

115115
## Known Limitations
116-
116+
- Async utilities `waitForElement`, `waitForElementToBeRemoved` and `waitForDomChange` are not exposed. Consider using a `find*` query.
117117
- `fireEvent` method is not exposed, use puppeteer's built-ins instead.
118118
- `expect` assertion extensions are not available.
119119

lib/typedefs.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {BoundFunctions, Matcher, MatcherOptions, SelectorMatcherOptions, WaitForElementOptions} from '@testing-library/dom'
1+
import {Matcher, MatcherOptions, SelectorMatcherOptions, WaitForElementOptions} from '@testing-library/dom'
22
import {ElementHandle} from 'puppeteer'
33

44
type Element = ElementHandle
@@ -61,6 +61,20 @@ interface IQueryMethods {
6161
findAllByDisplayValue(el: Element, m: Matcher, opts?: SelectorMatcherOptions, waitForOpts?: WaitForElementOptions): Promise<Element[]>
6262
}
6363

64+
export type BoundFunction<T> = T extends (
65+
attribute: string,
66+
element: Element,
67+
text: infer P,
68+
options: infer Q,
69+
) => infer R
70+
? (text: P, options?: Q) => R
71+
: T extends (a1: any, text: infer P, options: infer Q, waitForElementOptions: infer W) => infer R
72+
? (text: P, options?: Q, waitForElementOptions?: W) => R
73+
: T extends (a1: any, text: infer P, options: infer Q) => infer R
74+
? (text: P, options?: Q) => R
75+
: never;
76+
export type BoundFunctions<T> = { [P in keyof T]: BoundFunction<T[P]> };
77+
6478
export interface IScopedQueryUtils extends BoundFunctions<IQueryMethods> {
6579
getQueriesForElement(): IScopedQueryUtils
6680
getNodeText(): Promise<string>

0 commit comments

Comments
 (0)