question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introduce non case sensitive matching for cy.contains()

See original GitHub issue

Current 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:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
Bahaa-Addincommented, Jun 11, 2019

I solved it using a regex with i flag for case insensitive : cy.contains(/capital sentence/i)

8reactions
vedmantcommented, Feb 7, 2019

I’d also need case insensitive contains method, maybe add some options to it?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found