Escape Regular Expression Text When Using cy.contains Command

Опубликовано: 25 Июль 2023
на канале: 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...


Смотрите видео Escape Regular Expression Text When Using cy.contains Command онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал gleb bahmutov 25 Июль 2023. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 605 раз и оно понравилось 28 посетителям.