-1

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 *');
Daniel
  • 7,684
  • 7
  • 52
  • 76

1 Answers1

1

Try

test.getByText(/^Read the rules \*$/)

To test regex you can use

https://regex101.com/

Docs about regex in testing-library are here

https://testing-library.com/docs/queries/about/

Second option:

test.getByText(content => content === 'Read the rules *');
Daniel
  • 7,684
  • 7
  • 52
  • 76