Skip to content

Commit

Permalink
docs(route2): document dynamic request aliasing (#3300)
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig authored Nov 4, 2020
1 parent b6829e4 commit 1f7c36c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions source/api/commands/route2.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ cy.wait('@someRoute').its('response.statusCode').should('eq', 500)
cy.wait('@someRoute').its('response.body').should('include', 'id')
```
### Aliasing individual requests
Aliases can be set on a per-request basis by setting the `alias` property of the intercepted request:
```js
cy.route2('POST', '/graphql', (req) => {
if (req.body.includes('mutation')) {
req.alias = 'gqlMutation'
}
})

// assert that a matching request has been made
cy.wait('@gqlMutation')
```
## Stubbing a response
### With a string
Expand Down

0 comments on commit 1f7c36c

Please sign in to comment.