About You
Your Needs
Finish

Schedule a demo to learn more.

Please provide your first name
Please provide your last name?
Please provide your company's name?
What is the size of your company?
What is your country/permanent residence?
In which state do you live?
In which state do you live?
By signing up, I agree with Iterable’s privacy policy. I understand I can unsubscribe at any time.
What channels are you currently using? (Optional)
Please provide how many emails are you sending per month
Please provide your primary use case
Thank you !

Thanks for contacting us, we’ll be in touch shortly.

Learn Cypress.io the Hard Way: Case-Insensitive

During the web development process, sometimes values in HTML have inconsistent capitalization, which will lead to flaky tests. Sometimes, the tests will look for lowercase text, but the actual text value will be in uppercase. One of the common practices to improve such a flaky test is to make the text in case-insensitive way. In this post, I will show you four different ways to make the text case insensitive.

The first approach is to use Cypress built-in feature to ignore case sensitivity. In this approach, the test will pass even if the text value in HTML is expected text instead of Expected Text. Cypress will ignore the uppercase and only check the actual text content. You can turn on and off this feature by changing the value of matchCase from false to true.

The second approach is to use Regex to ignore case sensitivity. In this approach, the i flag indicates that case should be ignored while attempting a match in a string.

The third approach is to change the string to lowercase first before attempting a match. In this approach, the .toLowerCase(); function will convert all the alphabetic characters in a string to a lowercase string.

The fourth approach is converting the characters in a string to lowercase by using an ASCII table. In the table below, you will see that #65 to #90 represent uppercase A to Z , whereas #97 to #122 present lowercase a to z. As such, if a character has a value between #65 to #90, we know this character is in upper case. By adding 32 to that character’s number, we can convert that character to lowercase.

Search Posts