Skip to content

Allow dynamically matching requests with a function #387

@davidnorth

Description

@davidnorth

To allow highly flexible matching of which requests you want to stub, we could add the option to accept a function instead of a fixed method/URL. This would recieve the request object (or some wrapper around it). The motivation is that I have and SPA that uses a GraphQL backend where all requests have the same URL and I want to filter them by the query name which is sent as a parameter in the POST body.

cy.route({
  matcher: (request) => !! request.body.match(//)
})

Metadata

Metadata

Assignees

Labels

pkg/driverThis is due to an issue in the packages/driver directorytopic: networktype: featureNew feature that does not currently exist

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions