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
10 changes: 1 addition & 9 deletions content/api/commands/and.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,7 @@ cy.get('button')

### Differences

### What's the difference between `.then()` and `.should()`/`.and()`?

Using `.then()` allows you to use the yielded subject in a callback function and
should be used when you need to manipulate some values or do some actions.

When using a callback function with `.should()` or `.and()`, on the other hand,
there is special logic to rerun the callback function until no assertions throw
within it. You should be careful of side affects in a `.should()` or `.and()`
callback function that you would not want performed multiple times.
::include{file=partials/then-should-and-difference.md}

## Rules

Expand Down
10 changes: 1 addition & 9 deletions content/api/commands/should.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,7 @@ cy.get('button')

### Differences

### What's the difference between `.then()` and `.should()`/`.and()`?

Using `.then()` allows you to use the yielded subject in a callback function and
should be used when you need to manipulate some values or do some actions.

When using a callback function with `.should()` or `.and()`, on the other hand,
there is special logic to rerun the callback function until no assertions throw
within it. You should be careful of side affects in a `.should()` or `.and()`
callback function that you would not want performed multiple times.
::include{file=partials/then-should-and-difference.md}

## Rules

Expand Down
10 changes: 1 addition & 9 deletions content/api/commands/then.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,7 @@ cy.get('button')

### Differences

### What's the difference between `.then()` and `.should()`/`.and()`?

Using `.then()` allows you to use the yielded subject in a callback function and
should be used when you need to manipulate some values or do some actions.

When using a callback function with `.should()` or `.and()`, on the other hand,
there is special logic to rerun the callback function until no assertions throw
within it. You should be careful of side affects in a `.should()` or `.and()`
callback function that you would not want performed multiple times.
::include{file=partials/then-should-and-difference.md}

## Rules

Expand Down
9 changes: 9 additions & 0 deletions content/partials/then-should-and-difference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### What's the difference between `.then()` and `.should()`/`.and()`?

Using `.then()` allows you to use the yielded subject in a callback function and
should be used when you need to manipulate some values or do some actions.

When using a callback function with `.should()` or `.and()`, on the other hand,
there is special logic to rerun the callback function until no assertions throw
within it. You should be careful of side affects in a `.should()` or `.and()`
callback function that you would not want performed multiple times.