cypress-io / cypress-documentation

Cypress Documentation including Guides, API, Plugins, Examples, & FAQ.
https://docs.cypress.io
MIT License
938 stars 1.04k forks source link

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

Open m-gug opened 1 year ago

m-gug commented 1 year ago

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?

nagash77 commented 1 year ago

@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')
MikeMcC399 commented 3 weeks ago

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?

jennifer-shehane commented 3 weeks ago

Open to a PR for this.