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 11import { ClientFunction , Selector } from "testcafe" ;
22import { 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" ;
94
105declare global {
116 interface Window {
@@ -71,9 +66,14 @@ function isSelector(sel: any): sel is Selector {
7166 return sel . constructor . name === SELECTOR_TYPE ;
7267}
7368
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+ ) => {
7575 const query = queryName . replace ( "find" , "query" ) as T ;
76- return ( matcher : Matcher , options ?: QueryOptions ) => {
76+ return ( matcher : Matcher , options ?: Options ) => {
7777 return Selector (
7878 ( ) =>
7979 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" ;
82
93export type Options = Pick < Config , "testIdAttribute" > ;
104
@@ -17,7 +11,4 @@ export type TestcafeBoundFunctions<T> = {
1711} ;
1812
1913export type QueryName = keyof typeof queries ;
20-
21- export type QueryOptions = MatcherOptions ;
22-
2314export type WithinSelectors = TestcafeBoundFunctions < typeof queries > ;
Original file line number Diff line number Diff line change @@ -19,3 +19,9 @@ test("getByLabelText", async (t) => {
1919 "Hello Input Labelled By Id"
2020 ) ;
2121} ) ;
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