I'm trying to do some Cypress assertions to see whether or not it contains one or another string. It can be in English or Spanish, so either one should pass the test.
cy.get(el).should('contain', 'submit').or('contain', 'enviar')
obviously doesnt work.
const runout = ['submit', 'enviar']
const el = '[data-test=btn-submit]'
function checkArray(arr, el) {
for(let i = 0; i < arr.length; i++) {
if(cy.get(el).contains(arr[i])) {
return true
} else {
if (i === arr.length) {
return false
}
}
}
}
cy.expect(checkArray(runout,el)).to.be.true
fails the test, still checking both strings.