Introduce non case sensitive matching for cy.contains()
See original GitHub issueCurrent behavior:
cy.contains('Capital Sentence') does not match
<span class="capitalize"> capital sentence </span>
where:
.capitalize {
text-transform: capitalize;
}
Is this expected?
Desired behavior:
I assumed it would match because that’s what the user sees. However the underlying text in the DOM is indeed capital sentence.
Steps to reproduce:
Versions
Cypress: 3.0.1 Chrome, Mac OS Mojave
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Cypress - way to make contains() work in case-insensitive way
So, this is my current workaround for non case sensitive text matching, until Cypress includes this feature for cy.contains()
Read more >contains - Cypress Documentation
You can use a space character in cy.contains() to match text in the HTML that uses a non-breaking space entity . ......
Read more >Assertions | Cypress examples (v9.5.0) - Gleb Bahmutov
To make an assertion about the current subject, use the .should() command. ... can ignore the case and perform case-insensitive match cy.get('#a-greeting') ...
Read more >Learn Cypress.io the hard way: Case-insensitive - Medium
The first approach is to use Cypress built-in feature to ignore case sensitivity. In this approach, the test will pass even if the...
Read more >Learn Cypress.io the Hard Way: Case-Insensitive - Iterable
The first approach is to use Cypress built-in feature to ignore case sensitivity. In this approach, the test will pass even if the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I solved it using a regex with
iflag for case insensitive :cy.contains(/capital sentence/i)I’d also need case insensitive contains method, maybe add some options to it?