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

docs(route2): document dynamic request aliasing #3300

Merged
merged 1 commit into from
Nov 4, 2020
Merged
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
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