File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const domLibraryAsString = readFileSync(
1212/* istanbul ignore next */
1313function mapArgument ( argument : any , index : number ) : any {
1414 return index === 0 && typeof argument === 'object' && argument . regex
15- ? new RegExp ( argument . regex )
15+ ? new RegExp ( argument . regex , argument . flags )
1616 : argument
1717}
1818
@@ -84,14 +84,16 @@ function createDelegateFor<T = DOMReturnType>(
8484 // @ts -ignore
8585 processHandleFn = processHandleFn || processQuery
8686
87+ const convertRegExp = ( regex : RegExp ) => ( { regex : regex . source , flags : regex . flags } )
88+
8789 return async function ( ...args : any [ ] ) : Promise < T > {
8890 // @ts -ignore
8991 const containerHandle : ElementHandle = contextFn ? contextFn . apply ( this , args ) : this
9092 // @ts -ignore
9193 const evaluateFn : EvaluateFn = { toString : ( ) => delegateFnToExecuteInPage }
9294
9395 // Convert RegExp to a special format since they don't serialize well
94- let argsToForward = args . map ( arg => ( arg instanceof RegExp ? { regex : arg . source } : arg ) )
96+ let argsToForward = args . map ( arg => ( arg instanceof RegExp ? convertRegExp ( arg ) : arg ) )
9597 // Remove the container from the argsToForward since it's always the first argument
9698 if ( containerHandle === args [ 0 ] ) {
9799 argsToForward = args . slice ( 1 )
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ describe('lib/extend.ts', () => {
2626 } )
2727
2828 it ( 'should handle regex matching' , async ( ) => {
29- const element = await document . queryByText ( / H e l l o / )
29+ const element = await document . queryByText ( / H e L l O / i )
3030 expect ( element ) . toBeTruthy ( )
3131 /* istanbul ignore next */
3232 expect ( await page . evaluate ( el => el . textContent , element ) ) . toEqual ( 'Hello h1' )
You can’t perform that action at this time.
0 commit comments