Can anyone please help me with the below statement
I am trying to get the element by text which contains asterisk
const readButton = test.getByText('Read the rules *');
CodePudding user response:
Try
test.getByText(/^Read the rules \*$/)
To test regex you can use
Docs about regex in testing-library are here
https://testing-library.com/docs/queries/about/
Second option:
test.getByText(content => content === 'Read the rules *');