Skip to content

Commit

Permalink
docs: Document Cypress.Commands.addAll() (#4414)
Browse files Browse the repository at this point in the history
Co-authored-by: Emily Rohrbough <[email protected]>
  • Loading branch information
sainthkh and emilyrohrbough authored Apr 11, 2022
1 parent f6ab867 commit 18c3f99
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions content/api/cypress-api/custom-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ evaluated via an import statement in your
```javascript
Cypress.Commands.add(name, callbackFn)
Cypress.Commands.add(name, options, callbackFn)
Cypress.Commands.addAll(callbackObj)
Cypress.Commands.addAll(options, callbackObj)
Cypress.Commands.overwrite(name, callbackFn)
```

Expand All @@ -30,6 +32,10 @@ Cypress.Commands.overwrite(name, callbackFn)

```javascript
Cypress.Commands.add('login', (email, pw) => {})
Cypress.Commands.addAll({
login(email, pw) {},
visit(orig, url, options) {},
})
Cypress.Commands.overwrite('visit', (orig, url, options) => {})
```

Expand All @@ -43,6 +49,10 @@ The name of the command you're either adding or overwriting.

Pass a function that receives the arguments passed to the command.

**<Icon name="angle-right"></Icon> callbackObj** **_(Object)_**

An object with `callbackFn`s as properties.

**<Icon name="angle-right"></Icon> options** **_(Object)_**

Pass in an options object to define the implicit behavior of the custom command.
Expand Down

0 comments on commit 18c3f99

Please sign in to comment.