← Back to match
Cypress
Spy and stub network requests and responses.
PlatformWebunknownglobal
The Cypress intercept command lets you spy on and stub network requests and responses. It supports multiple syntaxes for spying only, spying with static response stubbing, and spying with dynamic route handlers. You can match requests by method, URL (string, glob, or RegExp), or a routeMatcher object whose optional properties include auth, headers, hostname, https, method, middleware, path, pathname, port, query, times, and url. staticResponse objects can be used to statically define stubbed responses (and may include { log: false } to disable logs). routeHandler functions allow dynamic stubbing and request/response modification. All intercepts are automatically cleared before every test.

