cypress-documentation icon indicating copy to clipboard operation
cypress-documentation copied to clipboard

Documentation says it's unsafe to chain after .clear() but has an example with .clear().type("xyz")

Open m-gug opened this issue 2 years ago • 3 comments

Subject

chaining after .clear()

Description

The documentation (and the linting) says, that it is unsafe to chain commands after .clear(). https://docs.cypress.io/api/commands/clear#__docusaurus_skipToContent_fallback

But the same documentation has an example (https://docs.cypress.io/api/commands/clear#No-Args) where it chains a .type() command after the .clear(), which is a little confusing and inconsistent.

Is it safe to chain a type after a clear?

m-gug avatar Jul 12 '23 06:07 m-gug

@m-gug good catch! You should NOT chain off of clear()

I would suggest you do something like this instead:

cy.get('textarea').clear()
cy.get('textarea').type('Hello, World')

nagash77 avatar Jul 12 '23 18:07 nagash77

This also needs fixing for https://docs.cypress.io/api/commands/clear#Usage

@jennifer-shehane

If @jaffrepaul is no longer available, perhaps you could re-assign or remove the assignment?

MikeMcC399 avatar Aug 20 '24 12:08 MikeMcC399

Open to a PR for this.

jennifer-shehane avatar Aug 20 '24 14:08 jennifer-shehane