Skip to content

Conversation

duranbe
Copy link
Contributor

@duranbe duranbe commented Mar 9, 2025

This PR creates a new rule to disallow the usage of cy.get().get() as .get() is often misused as it is starting search from the document and the previously selected element.

@cypress-app-bot
Copy link

```

## Further Reading

Copy link
Collaborator

@MikeMcC399 MikeMcC399 Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly this should link to [cy.get()](https://on.cypress.io/api/get) (cy.get())

In the section https://docs.cypress.io/api/commands/get#Get-vs-Find it shows an example valid use of cy.get('#comparison').get('div')

cy.get('#comparison')
  .get('div')
  // finds the div.test-title outside the #comparison
  // and the div.feature inside
  .should('have.class', 'test-title')
  .and('have.class', 'feature')
cy.get('#comparison')
  .find('div')
  // the search is limited to the tree at #comparison element
  // so it finds div.feature only
  .should('have.length', 1)
  .and('have.class', 'feature')

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duranbe

I suggest that you either remove the heading ## Further Reading if there is no content for this section, or you link to the documentation page

MikeMcC399

This comment was marked as resolved.

@jennifer-shehane jennifer-shehane self-requested a review March 10, 2025 14:47
@jennifer-shehane
Copy link
Member

@duranbe Do you have time to address feedback here?

@MikeMcC399

This comment was marked as resolved.

@duranbe
Copy link
Contributor Author

duranbe commented Apr 4, 2025

Hey - sorry missed this ! Thanks for the feedbacks, addressing them

@MikeMcC399

This comment was marked as resolved.

Copy link
Collaborator

@MikeMcC399 MikeMcC399 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duranbe

Thank you for resolving the comments!

@jennifer-shehane jennifer-shehane merged commit 2c911ac into cypress-io:master Apr 22, 2025
10 checks passed
@jennifer-shehane
Copy link
Member

🎉 This PR is included in version 4.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new rule to prevent chaining get queries
4 participants