How to pass a an argument to getByText in react Testing Library? April 8, 2024 by Tarik If you have const x = "Some string" To test for x using regex, getByText(new RegExp(x, "i"))