I'm trying to E2E test a web application using cypress/cucumber.
The page I'm testing has a H1 title I want to check the contents of. Normally I would use something like cy.get('H1').should('contain.text', 'some longpagetitle')
However there is a soft hyphen (­
to be precise) in the title. So the above line fails.. I rather not put the soft hyphen in my assertion.
Is it possible to assert text while ignoring soft hyphens?
CodePudding user response:
Apply a replace to the text,
<h1>extra­ordinarily lond­winded text</h1>
cy.get('h1')
.invoke('text')
.then(text => text.replace(/\u00AD/g,''))
.should('eq', 'extraordinarily longwinded text') // passes