Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TextMatch with Variable case-insensitive #1166

Unanswered
MentalGear asked this question in Q&A
Discussion options

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.

You must be logged in to vote

Replies: 1 comment

Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /