Skip to content

Clarify usage for commands marked as unsafe to chain further commands #6185

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

Open
rsi21 opened this issue May 16, 2025 · 3 comments · May be fixed by #6186
Open

Clarify usage for commands marked as unsafe to chain further commands #6185

rsi21 opened this issue May 16, 2025 · 3 comments · May be fixed by #6186

Comments

@rsi21
Copy link

rsi21 commented May 16, 2025

Description

Hi,

I wanted some more information about commands indicating that:

**It is [unsafe](https://docs.cypress.io/app/core-concepts/retry-ability#Only-queries-are-retried) to chain further commands that rely on the subject after ...**

There are several commands in this case like:

  • type()
  • focus()
  • blur()
  • check()
  • ...

Does it mean these kind of commands must not be chained at all with any other command ? (except for assertions)

I ask that because at the same time they are often code samples showing chaining with these kind of commands like:

  1. here a case with 2 of themn chained:
    https://docs.cypress.io/api/commands/focus#Focus-type-and-blur-a-textarea
    cy.get('textarea').focus().type('Nice Product!').blur()

  2. here with a type() followed by a blur():
    https://docs.cypress.io/api/commands/blur#Blur-the-comment-input
    cy.get('[name="comment"]').type('Nice Product!').blur()

Thanks

@jennifer-shehane
Copy link
Member

@rsi21 Yes, we should update these examples to follow our unsafe to chain rules. Our estlint plugin has a specific rule for this if you want this enforced: https://github.com/cypress-io/eslint-plugin-cypress

@jennifer-shehane
Copy link
Member

PR here: #6186

@rsi21
Copy link
Author

rsi21 commented May 16, 2025

Hi @jennifer-shehane,
Thanks for the quick answer and for the plugin, i just tried the plugin and it works great!

Regarding your PR, 2 quick points:

  • i just see this one missing docs/api/commands/type.mdx
  • and this syntax is unsafe too ?
    cy.get('[data-cy="dropdown-item"]').should('be.visible').click()

thks

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

Successfully merging a pull request may close this issue.

2 participants