Home > Mobile >  How to read a button which contains text with asterisk in javascript
How to read a button which contains text with asterisk in javascript

Time:12-30

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

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 *');
  • Related