Escape Regular Expression Text When Using cy.contains Command

Published: 25 July 2023
on channel: 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...


On this page of the site you can watch the video online Escape Regular Expression Text When Using cy.contains Command with a duration of hours minute second in good quality, which was uploaded by the user gleb bahmutov 25 July 2023, share the link with friends and acquaintances, this video has already been watched 605 times on youtube and it was liked by 28 viewers. Enjoy your viewing!