Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document new focus assertion #1372

Merged
merged 3 commits into from
May 1, 2019
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
9 changes: 9 additions & 0 deletions source/api/commands/should.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ cy.get('button').should('have.id', 'new-user').then(($button) => {
cy.get('#header a').should('have.attr', 'href', '/users')
```

## Focus

### Assert an input is focused after button click

```javascript
cy.get('#btn-focuses-input').click()
cy.get('#input-receives-focus').should('have.focus') // equivalent to should('be.focused')
```

## Function

Passing a function to `.should()` enables you to make multiple assertions on the yielded subject. This also gives you the opportunity to *massage* what you'd like to assert on.
Expand Down
1 change: 1 addition & 0 deletions source/guides/references/assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ You will commonly use these chainers after using DOM commands like: {% url `cy.g
| hidden | `expect($el).to.be.hidden` |
| selected | `expect($option).not.to.be.selected` |
| checked | `expect($input).not.to.be.checked` |
| focus[ed] | `expect($input).not.to.be.focused`<br>`expect($input).to.have.focus` |
| enabled | `expect($input).to.be.enabled` |
| disabled | `expect($input).to.be.disabled` |
| empty | `expect($el).not.to.be.empty` |
Expand Down