-
Notifications
You must be signed in to change notification settings - Fork 728
TextMatch with Variable case-insensitive #1166
Unanswered
MentalGear
asked this question in
Q&A
-
After going over the TextMatch page, I noticed there are regex matchers one can use like /first name/i
, but I couldn't find out how to use these with a variable.
Example with fill function:
function fillInputElements(inputValuePair: { [id: string]: string }) { for (const [key, value] of Object.entries(inputValuePair)) { const inputEl = screen.getByRole('textbox', { name: key }) inputEl.value = value } } fillInputElements({ 'First Name': 'John Simpleton2', 'Last Name': 'Some LastName', })
How to use the key with a case-insensitive match, or how can I make all role matches lowercase ?
I can't use exact: false as this would also introduce partial string matching which is something I don't want.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
You can create a RegExp from a string. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp on how to do that.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment