Files
cypress/docs/source/api/commands/end.md
T
Loren Norman f947e0c55d Merge remote-tracking branch 'origin/master'
# Conflicts:
#	docs/source/guides/getting-started/installing-cypress.md
2017-06-13 15:49:54 -04:00

1.1 KiB

title, comments
title comments
end false

End a chain of commands.

Syntax

.end()

Usage

.end() should be chained off another cy command.

{% fa fa-check-circle green %} Valid Usage

cy.contains('ul').end()   // Yield 'null' instead of 'ul' element

{% fa fa-exclamation-triangle red %} Invalid Usage

cy.end()                  // Does not make sense to chain off 'cy'

Yields

.end() yields null.

Examples

.end() is useful when you want to end a chain of commands and force the next command to not receive what was yielded in the previous command.

cy
  .contains('User: Cheryl').click().end() // yield null
  .contains('User: Charles').click()      // contains looks for content in document now

Alternatively, you can always start a new chain of commands of of cy.

cy.contains('User: Cheryl').click()
cy.contains('User: Charles').click()  // contains looks for content in document now

Command Log

.end() does not log in the command log

See also

  • {% url .root() root %}
  • {% url .within() within %}