Escape Regular Expression Text When Using cy.contains Command

Pubblicato il: 25 luglio 2023
sul canale di: gleb bahmutov
605
28

This video shows how to escape special characters like "$", "[]", and "^" when creating regular expressions to use with cy.contains command. You can escape the characters yourself or use the Lodash method Cypress._.escapeRegExp bundled with Cypress to do it for you
const suffix = '$/day'
const regex = new RegExp(Cypress._.escapeRegExp(suffix))
cy.contains(regex).should('have.id', 'rate')
Find the full recipe at https://glebbahmutov.com/cypress-exam...


In questa pagina del sito puoi guardare il video online Escape Regular Expression Text When Using cy.contains Command della durata di ore minuti seconda in buona qualità , che l'utente ha caricato gleb bahmutov 25 luglio 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 605 volte e gli è piaciuto 28 spettatori. Buona visione!