This repository was archived by the owner on Aug 6, 2025. It is now read-only.
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 @@ -48,7 +48,10 @@ interface IQueryMethods {
4848}
4949
5050type 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 ] >
5255}
5356
5457export interface IScopedQueryUtils extends IScopedQueryMethods {
Original file line number Diff line number Diff line change @@ -80,6 +80,23 @@ describe('lib/extend.ts', () => {
8080 expect ( text ) . toEqual ( [ 'Hello h1' , 'Hello h2' , 'Hello h3' ] )
8181 } )
8282
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+
83100 it ( 'should scope results to element' , async ( ) => {
84101 const scope = await document . $ ( '#scoped' )
85102 const element = await scope ! . queryByText ( / H e l l o / )
You can’t perform that action at this time.
0 commit comments