File tree Expand file tree Collapse file tree 3 files changed +15
-18
lines changed Expand file tree Collapse file tree 3 files changed +15
-18
lines changed Original file line number Diff line number Diff line change 1
1
import { ClientFunction , Selector } from "testcafe" ;
2
2
import { Matcher , queries } from "@testing-library/dom" ;
3
- import type {
4
- Options ,
5
- QueryName ,
6
- QueryOptions ,
7
- WithinSelectors ,
8
- } from "./types" ;
3
+ import type { Options , QueryName , WithinSelectors } from "./types" ;
9
4
10
5
declare global {
11
6
interface Window {
@@ -71,9 +66,14 @@ function isSelector(sel: any): sel is Selector {
71
66
return sel . constructor . name === SELECTOR_TYPE ;
72
67
}
73
68
74
- const bindFunction = < T extends QueryName > ( queryName : T ) => {
69
+ const bindFunction = <
70
+ T extends QueryName ,
71
+ Options = Parameters < typeof queries [ T ] > [ 2 ]
72
+ > (
73
+ queryName : T
74
+ ) => {
75
75
const query = queryName . replace ( "find" , "query" ) as T ;
76
- return ( matcher : Matcher , options ?: QueryOptions ) => {
76
+ return ( matcher : Matcher , options ?: Options ) => {
77
77
return Selector (
78
78
( ) =>
79
79
window . TestingLibraryDom [ query ] ( document . body , matcher , options ) as
Original file line number Diff line number Diff line change 1
- import {
2
- Config ,
3
- BoundFunction ,
4
- queries ,
5
- Matcher ,
6
- MatcherOptions ,
7
- } from "@testing-library/dom" ;
1
+ import { Config , BoundFunction , queries } from "@testing-library/dom" ;
8
2
9
3
export type Options = Pick < Config , "testIdAttribute" > ;
10
4
@@ -17,7 +11,4 @@ export type TestcafeBoundFunctions<T> = {
17
11
} ;
18
12
19
13
export type QueryName = keyof typeof queries ;
20
-
21
- export type QueryOptions = MatcherOptions ;
22
-
23
14
export type WithinSelectors = TestcafeBoundFunctions < typeof queries > ;
Original file line number Diff line number Diff line change @@ -19,3 +19,9 @@ test("getByLabelText", async (t) => {
19
19
"Hello Input Labelled By Id"
20
20
) ;
21
21
} ) ;
22
+
23
+ test ( "getByRole" , async ( t ) => {
24
+ await t . click (
25
+ screen . getByRole ( "textbox" , { name : "Label For Input Labelled By Id" } )
26
+ ) ;
27
+ } ) ;
You can’t perform that action at this time.
0 commit comments