I have troubles asserting button text in Cypress with RegEx (I need an exact match).
HTML
<button data-test-key="forward-button">Nexto</button>
JS
const forwardButtonText = 'Nexto';
cy.find('button[data-test-key=forward-button]')
.should(
'contain',
new RegExp(`^${forwardButtonText}$`, 'gi'),
);
I followed this SO thread, but it doesn't seem to work for me.
I'm getting an AssertionError
.
Timed out retrying after 4000ms: expected '<button>' to contain /^Nexto$/gi
When I put the string Nexto
manually, it passes.
Thanks in advance for any advice!