Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions docs/api/commands/end.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
---
title: 'end | Cypress Documentation'
description: End a chain of commands in Cypress.
description: 'Deprecated: End a chain of commands in Cypress.'
sidebar_label: end
sidebar_custom_props: { 'deprecated_label': true }
---

<ProductHeading product="app" />

:::caution

<strong>Deprecated</strong>

`.end()` was deprecated in Cypress `15.15.0` and will be removed in a future
major version.

Instead of using `.end()` to break a chain, start a new chain of commands off
of `cy`:

<Badge type="danger">Before</Badge>

```javascript
cy.get('#user-cheryl').click().end().get('#user-charles').click()
```

<Badge type="success">After</Badge>

```javascript
cy.get('#user-cheryl').click()
cy.get('#user-charles').click()
```

:::

# end

End a chain of commands.
Expand All @@ -21,7 +47,7 @@ End a chain of commands.
<Icon name="check-circle" color="green" /> **Correct Usage**

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

<Icon name="exclamation-triangle" color="red" /> **Incorrect Usage**
Expand All @@ -40,18 +66,18 @@ cy.end()
command to not receive what was yielded in the previous command.

```javascript
cy.contains('User: Cheryl')
cy.get('#user-cheryl')
.click()
.end() // yield null
.contains('User: Charles')
.click() // contains looks for content in document now
.get('#user-charles')
.click() // get looks for the element in the document now
```

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

```javascript
cy.contains('User: Cheryl').click()
cy.contains('User: Charles').click() // contains looks for content in document now
cy.get('#user-cheryl').click()
cy.get('#user-charles').click() // get looks for the element in the document now
```

## Rules
Expand Down
Loading