File tree 2 files changed +5
-3
lines changed
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const domLibraryAsString = readFileSync(
12
12
/* istanbul ignore next */
13
13
function mapArgument ( argument : any , index : number ) : any {
14
14
return index === 0 && typeof argument === 'object' && argument . regex
15
- ? new RegExp ( argument . regex )
15
+ ? new RegExp ( argument . regex , argument . flags )
16
16
: argument
17
17
}
18
18
@@ -84,14 +84,16 @@ function createDelegateFor<T = DOMReturnType>(
84
84
// @ts -ignore
85
85
processHandleFn = processHandleFn || processQuery
86
86
87
+ const convertRegExp = ( regex : RegExp ) => ( { regex : regex . source , flags : regex . flags } )
88
+
87
89
return async function ( ...args : any [ ] ) : Promise < T > {
88
90
// @ts -ignore
89
91
const containerHandle : ElementHandle = contextFn ? contextFn . apply ( this , args ) : this
90
92
// @ts -ignore
91
93
const evaluateFn : EvaluateFn = { toString : ( ) => delegateFnToExecuteInPage }
92
94
93
95
// 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 ) )
95
97
// Remove the container from the argsToForward since it's always the first argument
96
98
if ( containerHandle === args [ 0 ] ) {
97
99
argsToForward = args . slice ( 1 )
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ describe('lib/extend.ts', () => {
26
26
} )
27
27
28
28
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 )
30
30
expect ( element ) . toBeTruthy ( )
31
31
/* istanbul ignore next */
32
32
expect ( await page . evaluate ( el => el . textContent , element ) ) . toEqual ( 'Hello h1' )
You can’t perform that action at this time.
0 commit comments