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