File tree 2 files changed +21
-1
lines changed 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,10 @@ interface IQueryMethods {
48
48
}
49
49
50
50
type IScopedQueryMethods = {
51
- [ K in keyof IQueryMethods ] : ( m : Matcher , opts ?: MatcherOptions ) => ReturnType < IQueryMethods [ K ] >
51
+ [ K in keyof IQueryMethods ] : (
52
+ m : Matcher ,
53
+ opts ?: Parameters < IQueryMethods [ K ] > [ 2 ] ,
54
+ ) => ReturnType < IQueryMethods [ K ] >
52
55
}
53
56
54
57
export interface IScopedQueryUtils extends IScopedQueryMethods {
Original file line number Diff line number Diff line change @@ -80,6 +80,23 @@ describe('lib/extend.ts', () => {
80
80
expect ( text ) . toEqual ( [ 'Hello h1' , 'Hello h2' , 'Hello h3' ] )
81
81
} )
82
82
83
+ it ( 'should handle the queryAll* methods with a selector' , async ( ) => {
84
+ const elements = await document . queryAllByText ( / H e l l o / , { selector : 'h2' } )
85
+ expect ( elements ) . toHaveLength ( 1 )
86
+
87
+ const text = await page . evaluate ( el => el . textContent , elements [ 0 ] )
88
+
89
+ expect ( text ) . toEqual ( 'Hello h2' )
90
+ } )
91
+
92
+ it ( 'should handle the getBy* methods with a selector' , async ( ) => {
93
+ const element = await document . getByText ( / H e l l o / , { selector : 'h2' } )
94
+
95
+ const text = await page . evaluate ( el => el . textContent , element )
96
+
97
+ expect ( text ) . toEqual ( 'Hello h2' )
98
+ } )
99
+
83
100
it ( 'should scope results to element' , async ( ) => {
84
101
const scope = await document . $ ( '#scoped' )
85
102
const element = await scope ! . queryByText ( / H e l l o / )
You can’t perform that action at this time.
0 commit comments