Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show correct error message when a regex starting with = is passed to cy.contains. #21388

Merged
merged 2 commits into from May 18, 2022

Conversation

sainthkh
Copy link
Contributor

@sainthkh sainthkh commented May 9, 2022

User facing changelog

Correct error message is shown and Cypress is properly retried when a regex starting with = is passed to cy.contains.

Additional details

  • Why was this change necessary? => Cypress doesn't work correctly when a regex starting with = is passed to cy.contains.
  • What is affected by this change? => N/A
  • Any implementation details to explain? => It was happening because Sizzle, jQuery selector engine escapes = to handle attribute selectors. I changed our jquery config code to handle this exceptional case.

How has the user experience changed?

// Before: Fail with Syntax Error message + doesn't retry.
// After: Timed out error message + retry.
cy.contains(/=[0-6]/) 

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 9, 2022

Thanks for taking the time to open a PR!

@sainthkh sainthkh marked this pull request as ready for review May 9, 2022 08:20
@sainthkh sainthkh requested a review from a team as a code owner May 9, 2022 08:20
@sainthkh sainthkh requested review from jennifer-shehane and removed request for a team May 9, 2022 08:20
@jennifer-shehane jennifer-shehane removed their request for review May 11, 2022 14:50
@BlueWinds
Copy link
Contributor

For anyone looking at this later, note that the selector already finds the element if it exists on the page - this PR just ensures that Cy waits for it to exist if it doesn't already. See #21108 (comment).

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 23, 2022

Released in 9.7.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.7.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unrecognized expression for regex that ends with /=\s+[0-6]/
3 participants