Escape Regular Expression Text When Using cy.contains Command

Publié le: 25 juillet 2023
sur la chaîne: 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...


Sur cette page du site, vous pouvez voir la vidéo en ligne Escape Regular Expression Text When Using cy.contains Command durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur gleb bahmutov 25 juillet 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 605 fois et il a aimé 28 téléspectateurs. Bon visionnage!