{
  "doc": {
    "id": "api/commands/intercept",
    "title": "cy.intercept()",
    "description": "Spy and stub network requests and responses.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/intercept.md",
    "version": "f97f06d85653c51afe39a9bd3cefda946807f150",
    "updated_at": "2026-10-05T21:01:45.863Z",
    "headings": [
      {
        "id": "api/commands/intercept#intercept",
        "text": "intercept",
        "level": 1
      },
      {
        "id": "api/commands/intercept#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/intercept#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/intercept#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/intercept#method-string",
        "text": "method (String)",
        "level": 4
      },
      {
        "id": "api/commands/intercept#url-string-glob-regexp",
        "text": "url (String, Glob, RegExp)",
        "level": 4
      },
      {
        "id": "api/commands/intercept#routematcher-routematcher",
        "text": "routeMatcher (RouteMatcher)",
        "level": 4
      },
      {
        "id": "api/commands/intercept#staticresponse-staticresponse-staticresponse-objects",
        "text": "staticResponse ([StaticResponse](#StaticResponse-objects))",
        "level": 4
      },
      {
        "id": "api/commands/intercept#routehandler-function",
        "text": "routeHandler (Function)",
        "level": 4
      },
      {
        "id": "api/commands/intercept#yields",
        "text": "Yields",
        "level": 3
      },
      {
        "id": "api/commands/intercept#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/intercept#matching-url",
        "text": "Matching url",
        "level": 3
      },
      {
        "id": "api/commands/intercept#matching-method",
        "text": "Matching method",
        "level": 3
      },
      {
        "id": "api/commands/intercept#matching-with-routematcher",
        "text": "Matching with RouteMatcher",
        "level": 3
      },
      {
        "id": "api/commands/intercept#matching-array-query-parameters",
        "text": "Matching array query parameters",
        "level": 3
      },
      {
        "id": "api/commands/intercept#pattern-matching",
        "text": "Pattern Matching",
        "level": 3
      },
      {
        "id": "api/commands/intercept#aliasing-an-intercepted-route",
        "text": "Aliasing an intercepted route",
        "level": 3
      },
      {
        "id": "api/commands/intercept#accessing-all-intercepted-requests",
        "text": "Accessing all intercepted requests",
        "level": 3
      },
      {
        "id": "api/commands/intercept#aliasing-individual-requests",
        "text": "Aliasing individual requests",
        "level": 3
      },
      {
        "id": "api/commands/intercept#waiting-on-a-request",
        "text": "Waiting on a request",
        "level": 3
      },
      {
        "id": "api/commands/intercept#with-url",
        "text": "With URL",
        "level": 4
      },
      {
        "id": "api/commands/intercept#with-routematcher",
        "text": "With RouteMatcher",
        "level": 4
      },
      {
        "id": "api/commands/intercept#using-the-yielded-object",
        "text": "Using the yielded object",
        "level": 4
      },
      {
        "id": "api/commands/intercept#waiting-on-multiple-intercepted-requests-at-once",
        "text": "Waiting on multiple intercepted requests at once",
        "level": 4
      },
      {
        "id": "api/commands/intercept#waiting-on-errors",
        "text": "Waiting on errors",
        "level": 4
      },
      {
        "id": "api/commands/intercept#asserting-that-an-intercepted-request-was-not-made",
        "text": "Asserting that an intercepted request was not made",
        "level": 3
      },
      {
        "id": "api/commands/intercept#stubbing-a-response",
        "text": "Stubbing a response",
        "level": 3
      },
      {
        "id": "api/commands/intercept#with-a-string",
        "text": "With a string",
        "level": 4
      },
      {
        "id": "api/commands/intercept#with-a-fixture",
        "text": "With a fixture",
        "level": 4
      },
      {
        "id": "api/commands/intercept#with-a-staticresponse-object",
        "text": "With a StaticResponse object",
        "level": 4
      },
      {
        "id": "api/commands/intercept#stubbing-a-server-error-or-a-network-failure",
        "text": "Stubbing a server error or a network failure",
        "level": 4
      },
      {
        "id": "api/commands/intercept#failing-an-intercepted-request-once-then-succeeding",
        "text": "Failing an intercepted request once, then succeeding",
        "level": 4
      },
      {
        "id": "api/commands/intercept#overriding-an-intercept-in-a-single-test",
        "text": "Overriding an intercept in a single test",
        "level": 3
      },
      {
        "id": "api/commands/intercept#using-the-routehandler-function",
        "text": "Using the routeHandler function",
        "level": 3
      },
      {
        "id": "api/commands/intercept#asserting-on-a-request",
        "text": "Asserting on a request",
        "level": 4
      },
      {
        "id": "api/commands/intercept#modifying-an-outgoing-request",
        "text": "Modifying an outgoing request",
        "level": 4
      },
      {
        "id": "api/commands/intercept#changing-query-parameters-with-req-query",
        "text": "Changing query parameters with req.query",
        "level": 4
      },
      {
        "id": "api/commands/intercept#adding-a-header-to-an-outgoing-request",
        "text": "Adding a header to an outgoing request",
        "level": 4
      },
      {
        "id": "api/commands/intercept#waiting-on-the-intercept",
        "text": "Waiting on the intercept",
        "level": 4
      },
      {
        "id": "api/commands/intercept#add-modify-or-delete-a-header-to-all-outgoing-requests",
        "text": "Add, modify or delete a header to all outgoing requests",
        "level": 4
      },
      {
        "id": "api/commands/intercept#dynamically-stubbing-a-response",
        "text": "Dynamically stubbing a response",
        "level": 4
      },
      {
        "id": "api/commands/intercept#returning-a-promise",
        "text": "Returning a Promise",
        "level": 4
      },
      {
        "id": "api/commands/intercept#passing-a-request-to-the-next-request-handler",
        "text": "Passing a request to the next request handler",
        "level": 4
      },
      {
        "id": "api/commands/intercept#disabling-logs-for-a-request",
        "text": "Disabling logs for a request",
        "level": 3
      },
      {
        "id": "api/commands/intercept#intercepting-a-response",
        "text": "Intercepting a response",
        "level": 3
      },
      {
        "id": "api/commands/intercept#asserting-on-a-response",
        "text": "Asserting on a response",
        "level": 4
      },
      {
        "id": "api/commands/intercept#modifying-the-real-server-response-with-req-continue",
        "text": "Modifying the real server response with req.continue()",
        "level": 4
      },
      {
        "id": "api/commands/intercept#returning-a-promise",
        "text": "Returning a Promise",
        "level": 4
      },
      {
        "id": "api/commands/intercept#throttle-or-delay-all-incoming-responses",
        "text": "Throttle or delay all incoming responses",
        "level": 4
      },
      {
        "id": "api/commands/intercept#request-response-modification-with-routehandler",
        "text": "Request/Response Modification with routeHandler",
        "level": 3
      },
      {
        "id": "api/commands/intercept#asserting-on-a-request",
        "text": "Asserting on a request",
        "level": 4
      },
      {
        "id": "api/commands/intercept#controlling-the-outgoing-request",
        "text": "Controlling the outgoing request",
        "level": 4
      },
      {
        "id": "api/commands/intercept#verifying-the-request-modification",
        "text": "Verifying the request modification",
        "level": 4
      },
      {
        "id": "api/commands/intercept#controlling-the-response",
        "text": "Controlling the response",
        "level": 4
      },
      {
        "id": "api/commands/intercept#returning-a-promise",
        "text": "Returning a Promise",
        "level": 4
      },
      {
        "id": "api/commands/intercept#stubbing-a-response-with-a-string",
        "text": "Stubbing a response with a string",
        "level": 4
      },
      {
        "id": "api/commands/intercept#intercepted-requests",
        "text": "Intercepted requests",
        "level": 2
      },
      {
        "id": "api/commands/intercept#request-object-properties",
        "text": "Request object properties",
        "level": 3
      },
      {
        "id": "api/commands/intercept#controlling-the-outbound-request-with-req-continue",
        "text": "Controlling the outbound request with req.continue()",
        "level": 3
      },
      {
        "id": "api/commands/intercept#providing-a-stub-response-with-req-reply",
        "text": "Providing a stub response with req.reply()",
        "level": 3
      },
      {
        "id": "api/commands/intercept#req-reply-shorthand",
        "text": "req.reply() shorthand",
        "level": 4
      },
      {
        "id": "api/commands/intercept#convenience-functions",
        "text": "Convenience functions",
        "level": 4
      },
      {
        "id": "api/commands/intercept#request-events",
        "text": "Request events",
        "level": 3
      },
      {
        "id": "api/commands/intercept#intercepted-responses",
        "text": "Intercepted responses",
        "level": 2
      },
      {
        "id": "api/commands/intercept#response-object-properties",
        "text": "Response object properties",
        "level": 3
      },
      {
        "id": "api/commands/intercept#ending-the-response-with-res-send",
        "text": "Ending the response with res.send()",
        "level": 3
      },
      {
        "id": "api/commands/intercept#res-send-shorthand",
        "text": "res.send() shorthand",
        "level": 4
      },
      {
        "id": "api/commands/intercept#convenience-functions",
        "text": "Convenience functions",
        "level": 4
      },
      {
        "id": "api/commands/intercept#staticresponse-objects",
        "text": "StaticResponse objects",
        "level": 2
      },
      {
        "id": "api/commands/intercept#interception-lifecycle",
        "text": "Interception lifecycle",
        "level": 2
      },
      {
        "id": "api/commands/intercept#request-phase",
        "text": "Request phase",
        "level": 3
      },
      {
        "id": "api/commands/intercept#response-phase",
        "text": "Response phase",
        "level": 3
      },
      {
        "id": "api/commands/intercept#glob-pattern-matching-urls",
        "text": "Glob Pattern Matching URLs",
        "level": 2
      },
      {
        "id": "api/commands/intercept#cypress-minimatch",
        "text": "Cypress.minimatch",
        "level": 3
      },
      {
        "id": "api/commands/intercept#minimatch-options",
        "text": "minimatch options",
        "level": 4
      },
      {
        "id": "api/commands/intercept#cy-intercept-and-test-performance",
        "text": "cy.intercept() and test performance",
        "level": 2
      },
      {
        "id": "api/commands/intercept#troubleshooting-a-cy-intercept-route-that-doesnt-match",
        "text": "Troubleshooting a cy.intercept() route that doesn't match",
        "level": 2
      },
      {
        "id": "api/commands/intercept#cy-intercept-and-request-caching",
        "text": "cy.intercept() and request caching",
        "level": 2
      },
      {
        "id": "api/commands/intercept#cy-intercept-and-cors-preflight-requests",
        "text": "cy.intercept() and CORS preflight requests",
        "level": 2
      },
      {
        "id": "api/commands/intercept#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/intercept#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/intercept#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "intercept"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Spy and stub network requests and responses."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Tip: We recommend you read the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/network-requests.md",
            "children": [
              {
                "type": "text",
                "value": "Network Requests"
              }
            ]
          },
          {
            "type": "text",
            "value": " guide first."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "All intercepts are automatically cleared before every test."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Find the section for what you want to do:"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "I want to…"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Use"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "See"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Wait for a request"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.intercept(url).as()` and `cy.wait()`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Waiting-on-a-request",
                    "children": [
                      {
                        "type": "text",
                        "value": "Waiting on a request"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Return fixed data"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "a "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#StaticResponse-objects",
                    "children": [
                      {
                        "type": "text",
                        "value": "`StaticResponse`"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Stubbing-a-response",
                    "children": [
                      {
                        "type": "text",
                        "value": "Stubbing a response"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Decide the response at request time"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.reply()`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Providing-a-stub-response-with-reqreply",
                    "children": [
                      {
                        "type": "text",
                        "value": "Providing a stub response with `req.reply()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Change what's sent to the server"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "a "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#routeHandler-Function",
                    "children": [
                      {
                        "type": "text",
                        "value": "`routeHandler`"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Modifying-an-outgoing-request",
                    "children": [
                      {
                        "type": "text",
                        "value": "Modifying an outgoing request"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Change the real response"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.continue()` with a callback"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Modifying-the-real-server-response-with-reqcontinue",
                    "children": [
                      {
                        "type": "text",
                        "value": "Modifying the real server response with `req.continue()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Test a server error or network failure"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`statusCode` or `forceNetworkError`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Stubbing-a-server-error-or-a-network-failure",
                    "children": [
                      {
                        "type": "text",
                        "value": "Stubbing a server error or a network failure"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Test a slow network"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`delay` or `throttleKbps`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Throttle-or-delay-all-incoming-responses",
                    "children": [
                      {
                        "type": "text",
                        "value": "Throttle or delay all incoming responses"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Check that a request was not made"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "the `.all` alias suffix"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Asserting-that-an-intercepted-request-was-not-made",
                    "children": [
                      {
                        "type": "text",
                        "value": "Asserting that an intercepted request was not made"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Keep intercepts from slowing tests"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "scoped routes and `blockHosts`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#cyintercept-and-test-performance",
                    "children": [
                      {
                        "type": "text",
                        "value": "`cy.intercept()` and test performance"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Fix an intercept that doesn't match"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "the Routes panel and `Cypress.minimatch()`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Troubleshooting-a-cyintercept-route-that-doesnt-match",
                    "children": [
                      {
                        "type": "text",
                        "value": "Troubleshooting a `cy.intercept()` route that doesn't match"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// spying only\ncy.intercept(url)\ncy.intercept(method, url)\ncy.intercept(routeMatcher)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See arguments "
          },
          {
            "type": "link",
            "title": null,
            "url": "#url-String-Glob-RegExp",
            "children": [
              {
                "type": "text",
                "value": "url"
              }
            ]
          },
          {
            "type": "text",
            "value": ", "
          },
          {
            "type": "link",
            "title": null,
            "url": "#method-String",
            "children": [
              {
                "type": "text",
                "value": "method"
              }
            ]
          },
          {
            "type": "text",
            "value": ", and "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeMatcher-RouteMatcher",
            "children": [
              {
                "type": "text",
                "value": "routeMatcher"
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// spying and response stubbing\ncy.intercept(url, staticResponse)\ncy.intercept(method, url, staticResponse)\ncy.intercept(routeMatcher, staticResponse)\ncy.intercept(url, routeMatcher, staticResponse)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#staticResponse-StaticResponse",
            "children": [
              {
                "type": "text",
                "value": "staticResponse"
              }
            ]
          },
          {
            "type": "text",
            "value": " argument"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// spying, dynamic stubbing, request modification, etc.\ncy.intercept(url, routeHandler)\ncy.intercept(method, url, routeHandler)\ncy.intercept(routeMatcher, routeHandler)\ncy.intercept(url, routeMatcher, routeHandler)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeHandler-Function",
            "children": [
              {
                "type": "text",
                "value": "routeHandler"
              }
            ]
          },
          {
            "type": "text",
            "value": " argument"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// Specifying request and response types\ntype CustomRequest = {\n  kind: 'custom_request'\n}\ntype CustomResponse = {\n  kind: 'custom_response'\n}\ncy.intercept<CustomRequest, CustomResponse>(url, (req) => {\n  req.body // .body of request will be of type CustomRequest\n  req.continue((res) => {\n    res.body // .body of response will be of type CustomResponse\n  })\n})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Usage"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Correct Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// spying\ncy.intercept('/users/**')\ncy.intercept('GET', '/users*')\ncy.intercept({\n  method: 'GET',\n  url: '/users*',\n  hostname: 'localhost',\n})\n\n// spying and response stubbing\ncy.intercept('POST', '/users*', {\n  statusCode: 201,\n  body: {\n    name: 'Peter Pan',\n  },\n})\n\n// spying, dynamic stubbing, request modification, etc.\ncy.intercept('/users*', { hostname: 'localhost' }, (req) => {\n  /* do something with request and/or response */\n})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Arguments"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "method (String)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Match the route to a specific "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods",
            "children": [
              {
                "type": "text",
                "value": "HTTP method"
              }
            ]
          },
          {
            "type": "text",
            "value": " (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `QUERY`, etc)."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If no method is defined Cypress will match all requests by default."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "url (String, Glob, RegExp)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Specify the URL to match. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Matching-url",
            "children": [
              {
                "type": "text",
                "value": "Matching `url`"
              }
            ]
          },
          {
            "type": "text",
            "value": " for examples."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Alternatively, specify the URL via the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeMatcher-RouteMatcher",
            "children": [
              {
                "type": "text",
                "value": "`routeMatcher`"
              }
            ]
          },
          {
            "type": "text",
            "value": " argument (below)."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "routeMatcher (`RouteMatcher`)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`routeMatcher` is an object used to match the incoming HTTP requests with this intercepted route."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "All properties are optional but all those that are set must match for the request to be intercepted. If a `string` is passed to any property, it will be glob-matched against the request using "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/utilities/minimatch.md",
            "children": [
              {
                "type": "text",
                "value": "`Cypress.minimatch`"
              }
            ]
          },
          {
            "type": "text",
            "value": " with the `{ matchBase: true }` minimatch option applied."
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Option"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Description"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "auth"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "HTTP Basic Authentication (`object` with keys `username` and `password`)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "headers"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "HTTP request headers (`object`). Header names match case-insensitively."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "hostname"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "HTTP request hostname"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "https"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`true`: only secure (https://) requests, `false`: only insecure (http://) requests"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "method"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "HTTP request method (matches any method by default). A string matches case-insensitively."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "middleware"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`true`: match route first and in defined order, `false`: match route in reverse order (default). `true` requires a `routeHandler` function."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "path"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "HTTP request path after the hostname, including query parameters"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "pathname"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Like `path`, but without query parameters"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "port"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "HTTP request port(s) (`number` or `Array`)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "query"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Parsed query string (`object`)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "resourceType deprecated"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "The resource type of the request. See "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Request-object-properties",
                    "children": [
                      {
                        "type": "text",
                        "value": "\"Request object properties\""
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " for a list of possible values for `resourceType`."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "times"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Maximum number of times to match (positive integer)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "url"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Full HTTP request URL"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#With-RouteMatcher",
            "children": [
              {
                "type": "text",
                "value": "examples"
              }
            ]
          },
          {
            "type": "text",
            "value": " below."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "staticResponse (`[StaticResponse](#StaticResponse-objects)`)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "By passing in a `StaticResponse` as the last argument, you can "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Stubbing-a-response",
            "children": [
              {
                "type": "text",
                "value": "statically define (stub) a response"
              }
            ]
          },
          {
            "type": "text",
            "value": " for matched requests. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse` object"
              }
            ]
          },
          {
            "type": "text",
            "value": " for the list of properties."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Additionally, you can pass `{ log: false }` with your `StaticResponse` to disable command logs for this intercept. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Disabling-logs-for-a-request",
            "children": [
              {
                "type": "text",
                "value": "\"Disabling logs for a request\""
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#With-a-StaticResponse-object",
            "children": [
              {
                "type": "text",
                "value": "Stubbing a response with a `StaticResponse` object"
              }
            ]
          },
          {
            "type": "text",
            "value": " for an example."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "routeHandler (`Function`)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The `routeHandler` function is called whenever a request is matched, with the first argument being the request object. From inside the callback, you have access to the entire request-response where you can modify the outgoing request, send a response, access the real response, and more."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Intercepted-requests",
            "children": [
              {
                "type": "text",
                "value": "\"Intercepted requests\""
              }
            ]
          },
          {
            "type": "text",
            "value": " and "
          },
          {
            "type": "link",
            "title": null,
            "url": "#RequestResponse-Modification-with-routeHandler",
            "children": [
              {
                "type": "text",
                "value": "Request/Response Modification with `routeHandler`"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Yields"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.intercept()` yields `null`, but can be aliased."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Waiting on an aliased `cy.intercept()` route using "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/wait.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "cy.wait()"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " will yield an object that contains information about the matching request/response cycle. See "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Using-the-yielded-object",
                    "children": [
                      {
                        "type": "text",
                        "value": "Using the yielded object"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " for examples of how to use this object."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.intercept` can be used solely for spying: to passively listen for matching routes and apply "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Aliasing-an-intercepted-route",
            "children": [
              {
                "type": "text",
                "value": "aliases"
              }
            ]
          },
          {
            "type": "text",
            "value": " to them without manipulating the request or its response in any way. This alone is powerful, since those aliases support "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Waiting-on-a-request",
            "children": [
              {
                "type": "text",
                "value": "waiting"
              }
            ]
          },
          {
            "type": "text",
            "value": " on these requests, resulting in more reliable tests."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Matching `url`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can provide the exact "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Arguments",
            "children": [
              {
                "type": "text",
                "value": "URL"
              }
            ]
          },
          {
            "type": "text",
            "value": " to match or use pattern-matching to match many URLs at once, either with globs or with regex. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Glob-Pattern-Matching-URLs",
            "children": [
              {
                "type": "text",
                "value": "Glob Pattern Matching URLs"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// match any request that exactly matches the URL\ncy.intercept('https://prod.cypress.io/users')\n\n// match any request that satisfies a glob pattern\ncy.intercept('/users\\\\?_limit=*')\n\n// match any request that satisfies a regex pattern\ncy.intercept(/\\/users\\?_limit=(3|5)$/)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Matching `method`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If you don't pass in a "
          },
          {
            "type": "link",
            "title": null,
            "url": "#method-String",
            "children": [
              {
                "type": "text",
                "value": "`method` argument"
              }
            ]
          },
          {
            "type": "text",
            "value": ", then all HTTP methods (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`, etc.) will match."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/users')\n// matches this: GET http://localhost/users\n// ...and this, too: POST http://localhost/users\n\ncy.intercept('GET', '/users')\n// matches this: GET http://localhost/users\n// ...but not this: POST http://localhost/users"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Matching with "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeMatcher-RouteMatcher",
            "children": [
              {
                "type": "text",
                "value": "RouteMatcher"
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Specifying a `method` and `url` to match can also be achieved by passing the `routeMatcher` object into `cy.intercept` instead:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// These both yield the same result:\ncy.intercept({ method: 'GET', url: '**/users' })\ncy.intercept('GET', '**/users')"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// Match any type of request with the pathname `/search`\n// and the query parameter 'q=some+terms'\ncy.intercept({\n  pathname: '/search',\n  query: {\n    q: 'some terms',\n  },\n}).as('searchForTerms')"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept({\n  // this RegExp matches any URL beginning with\n  // 'http://api.example.com/' and ending with '/edit' or '/save'\n  url: /^http:\\/\\/api\\.example\\.com\\/.*\\/(edit|save)/,\n  // matching requests must also contain this header\n  headers: {\n    'x-requested-with': 'exampleClient',\n  },\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// this example will cause 1 request to `/temporary-error`\n// to receive a network error and subsequent requests will\n// not match this `RouteMatcher`\ncy.intercept({ url: '/temporary-error', times: 1 }, { forceNetworkError: true })"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Matching array query parameters"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The `query` matcher compares each query parameter against a single string value, so it cannot match repeated, array-style parameters such as `?ids[]=1&ids[]=2`. The following will not match that request:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// 🚫 does not work - the array parameter is ignored\ncy.intercept({\n  pathname: '/items',\n  query: {\n    ids: '1',\n  },\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Instead, match the request with a `RegExp` `url`, or use a "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeHandler-Function",
            "children": [
              {
                "type": "text",
                "value": "`routeHandler`"
              }
            ]
          },
          {
            "type": "text",
            "value": " function and read the repeated values with "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/getAll",
            "children": [
              {
                "type": "text",
                "value": "`URLSearchParams.getAll()`"
              }
            ]
          },
          {
            "type": "text",
            "value": ":"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// match any request to `/items` that includes an `ids` parameter\ncy.intercept({ method: 'GET', url: /\\/items\\?.*ids/ }).as('items')"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// inspect every `ids` value and only stub when `1` is present\ncy.intercept('/items*', (req) => {\n  const ids = new URL(req.url).searchParams.getAll('ids[]')\n\n  if (ids.includes('1')) {\n    req.reply({ fixture: 'items.json' })\n  }\n}).as('items')"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Pattern Matching"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// match updates to the `/users` endpoint using glob matching\ncy.intercept({\n  method: '+(PUT|PATCH)',\n  url: '**/users/*',\n})\n// matches:\n//   PUT /users/1\n//   PATCH /users/1\n//\n// doesn't match:\n//   GET /users\n//   GET /users/1\n\n// same as above, but using regex\ncy.intercept({\n  method: /^(PUT|PATCH)$/,\n  url: '**/users/*',\n})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Aliasing an intercepted route"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "While `cy.intercept` doesn't yield anything, you can chain "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/as.md",
            "children": [
              {
                "type": "text",
                "value": "`.as`"
              }
            ]
          },
          {
            "type": "text",
            "value": " to it to create an "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/core-concepts/variables-and-aliases.md#Aliases",
            "children": [
              {
                "type": "text",
                "value": "alias"
              }
            ]
          },
          {
            "type": "text",
            "value": " which can be used to "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Waiting-on-a-request",
            "children": [
              {
                "type": "text",
                "value": "wait on a request"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/users').as('getAllUsers')\ncy.intercept('POST', '/users').as('createUser')"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Accessing all intercepted requests"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When an intercepted route is aliased, you can retrieve all matching intercepted requests using the `.all` suffix with "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/get.md",
            "children": [
              {
                "type": "text",
                "value": "`cy.get()`"
              }
            ]
          },
          {
            "type": "text",
            "value": ". This is useful when your application makes multiple requests to the same route and you need to assert on all of them."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/users').as('getUsers')\n\n// trigger multiple requests\ncy.visit('/users')\ncy.visit('/users')\n\n// yields an array of all interceptions for this alias\ncy.get('@getUsers.all').then((interceptions) => {\n  expect(interceptions).to.have.length(2)\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can also retrieve a specific intercept by its 1-based numeric index. Without any suffix, `cy.get('@alias')` returns the most recent intercepted request."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/users').as('getUsers')\n\ncy.visit('/users')\ncy.visit('/users')\n\n// yields the first intercepted request\ncy.get('@getUsers.1').its('response.statusCode').should('eq', 200)\n\n// yields the second intercepted request\ncy.get('@getUsers.2').its('response.statusCode').should('eq', 200)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Index `0` is not valid — indices start at `1`. These suffixes are not supported by "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/wait.md",
            "children": [
              {
                "type": "text",
                "value": "`cy.wait()`"
              }
            ]
          },
          {
            "type": "text",
            "value": ". Use `cy.get('@alias.all')` instead of `cy.wait('@alias.all')`."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Aliasing individual requests"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Aliases can be set on a per-request basis by setting the `alias` property of the intercepted request. This is especially useful when intercepting GraphQL requests:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('POST', '/graphql', (req) => {\n  if (req.body.hasOwnProperty('query') && req.body.query.includes('mutation')) {\n    req.alias = 'gqlMutation'\n  }\n})\n\n// assert that a matching request has been made\ncy.wait('@gqlMutation')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "For more guidance around aliasing requests with GraphQL, see "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/network-requests.md#Working-with-GraphQL",
            "children": [
              {
                "type": "text",
                "value": "Working with GraphQL"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Waiting on a request"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Use "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/wait.md",
            "children": [
              {
                "type": "text",
                "value": "cy.wait()"
              }
            ]
          },
          {
            "type": "text",
            "value": " with "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Aliasing-an-intercepted-route",
            "children": [
              {
                "type": "text",
                "value": "aliasing an intercepted route"
              }
            ]
          },
          {
            "type": "text",
            "value": " to wait for the request/response cycle to complete."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "With URL"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('http://example.com/settings').as('getSettings')\n\n// once a request to get settings responds, 'cy.wait' will resolve\ncy.wait('@getSettings')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "With "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeMatcher-RouteMatcher",
            "children": [
              {
                "type": "text",
                "value": "RouteMatcher"
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept({\n  url: 'http://example.com/search*',\n  query: { q: 'expected terms' },\n}).as('search')\n\n// once any type of request to search with a querystring\n// containing 'q=expected+terms' responds, 'cy.wait' will resolve\ncy.wait('@search')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Using the yielded object"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Using "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/wait.md",
            "children": [
              {
                "type": "text",
                "value": "cy.wait()"
              }
            ]
          },
          {
            "type": "text",
            "value": " on a `cy.intercept()` route alias yields an interception object which represents the request/response cycle:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.wait('@someRoute').then((interception) => {\n  // 'interception' is an object with properties\n  // 'id', 'request' and 'response'\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can chain "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/its.md",
            "children": [
              {
                "type": "text",
                "value": "`.its()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " and "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/should.md",
            "children": [
              {
                "type": "text",
                "value": "`.should()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " to assert against request/response cycles:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// assert that a request to this route\n// was made with a body that included 'user'\ncy.wait('@someRoute').its('request.body').should('include', 'user')\n\n// assert that a request to this route\n// received a response with HTTP status 500\ncy.wait('@someRoute').its('response.statusCode').should('eq', 500)\n\n// assert that a request to this route\n// received a response body that includes 'id'\ncy.wait('@someRoute').its('response.body').should('include', 'id')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Waiting on multiple intercepted requests at once"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Pass an array of aliases to "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/wait.md",
            "children": [
              {
                "type": "text",
                "value": "cy.wait()"
              }
            ]
          },
          {
            "type": "text",
            "value": " to wait for several requests. The requests can complete in any order, and the yielded array follows the order of the aliases you passed:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/users', { fixture: 'users.json' }).as('getUsers')\ncy.intercept('GET', '/projects', { body: [] }).as('getProjects')\n\n// the dashboard requests projects first, then users\ncy.get('[data-cy=\"load-dashboard\"]').click()\n\n// wait for both requests to complete, in any order\ncy.wait(['@getUsers', '@getProjects']).then((interceptions) => {\n  // `interceptions` is in the same order as the aliases\n  expect(interceptions[0].request.url).to.include('/users')\n  expect(interceptions[1].request.url).to.include('/projects')\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Every alias in the array waits at the same time, with the same `requestTimeout` and `responseTimeout`. Each alias's `requestTimeout` starts counting when `cy.wait()` starts, so it has to cover the slowest request to arrive. To give a slower request more time, wait on it separately:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.wait('@getUsers')\n\n// starts after `@getUsers` resolves, with a longer timeout\ncy.wait('@getProjects', { requestTimeout: 10000 })"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Waiting on errors"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can use "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/wait.md",
            "children": [
              {
                "type": "text",
                "value": "cy.wait()"
              }
            ]
          },
          {
            "type": "text",
            "value": " to wait on requests that end with network errors:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/should-err', { forceNetworkError: true }).as('err')\n\n// assert that this request happened\n// and that it ended in an error\ncy.wait('@err').should('have.property', 'error')"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Asserting that an intercepted request was not made"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To check that your app did not send a request, alias the route and assert that the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Accessing-all-intercepted-requests",
            "children": [
              {
                "type": "text",
                "value": "`.all` suffix"
              }
            ]
          },
          {
            "type": "text",
            "value": " yields an empty array:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('POST', '/analytics', { statusCode: 204 }).as('track')\n\ncy.get('#opt-out').click()\n\n// no request matched, so `.all` yields an empty array\ncy.get('@track.all').should('have.length', 0)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The assertion passes as soon as the array is empty, so it can't catch a request that your app sends later. Place it after something that proves the app has finished the action, such as an element that appears when it's done."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Stubbing a response"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "With a string"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// requests to '/update' will be fulfilled\n// with a body of \"success\"\ncy.intercept('/update', 'success')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "With a fixture"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// requests to '/users.json' will be fulfilled\n// with the contents of the \"users.json\" fixture\ncy.intercept('/users.json', { fixture: 'users.json' })"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "With a `StaticResponse` object"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "A "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse`"
              }
            ]
          },
          {
            "type": "text",
            "value": " object represents a response to an HTTP request, and can be used to stub routes:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const staticResponse = {\n  // some StaticResponse properties here...\n}\n\ncy.intercept('/projects', staticResponse)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Stub a response with a JSON body:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/projects', {\n  body: [{ projectId: '1' }, { projectId: '2' }],\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Stub headers, status code, and body all at once:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/not-found', {\n  statusCode: 404,\n  body: '404 Not Found!',\n  headers: {\n    'x-not-found': 'true',\n  },\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Stub response with a fixture that is read as a Buffer:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/not-found', {\n  fixture: 'media/gif.mp4,null',\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See also "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse` object"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Stubbing a server error or a network failure"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "A server error and a network failure reach your app differently, so test the one your app needs to handle. A `statusCode` of `500` sends a real HTTP response, and your app's request succeeds with an error status:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// the server responds with an error status code:\n// `fetch` resolves, and `response.ok` is `false`\ncy.intercept('GET', '/users', {\n  statusCode: 500,\n  body: { message: 'Internal Server Error' },\n}).as('getUsers')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`forceNetworkError` sends no response at all, the way an unreachable server or a dropped connection would:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// no response arrives at all: `fetch` rejects with a `TypeError`\ncy.intercept('GET', '/users', { forceNetworkError: true }).as('getUsers')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Failing an intercepted request once, then succeeding"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Combine "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeMatcher-RouteMatcher",
            "children": [
              {
                "type": "text",
                "value": "`times`"
              }
            ]
          },
          {
            "type": "text",
            "value": " with the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Interception-lifecycle",
            "children": [
              {
                "type": "text",
                "value": "matching order"
              }
            ]
          },
          {
            "type": "text",
            "value": " to test how your app recovers from a failed request. The route defined last matches first, and `times: 1` stops it from matching after one request, so the next request falls through to the earlier route:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// every request to `/users` gets the fixture...\ncy.intercept('GET', '/users', { fixture: 'users.json' }).as('getUsers')\n\n// ...except the first, which fails. This route is defined later, so it\n// matches first, and `times: 1` retires it after one match.\ncy.intercept(\n  { method: 'GET', url: '/users', times: 1 },\n  { statusCode: 500 }\n).as('getUsersFailure')\n\ncy.get('[data-cy=\"load-users\"]').click()\ncy.wait('@getUsersFailure').its('response.statusCode').should('eq', 500)\n\ncy.get('[data-cy=\"retry\"]').click()\ncy.wait('@getUsers').its('response.statusCode').should('eq', 200)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Overriding an intercept in a single test"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Because the route defined last matches first, a test can replace an intercept that a `beforeEach()` set up. Define the new route in the test and it wins for that test only, since all intercepts are cleared before the next one:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "beforeEach(() => {\n  // most tests see a list of users\n  cy.intercept('GET', '/users', { fixture: 'users.json' }).as('getUsers')\n})\n\nit('shows an empty state when there are no users', () => {\n  // defined later, so it matches first and wins for this test\n  cy.intercept('GET', '/users', { body: [] }).as('getUsers')\n\n  cy.get('[data-cy=\"load-users\"]').click()\n  cy.wait('@getUsers').its('response.body').should('have.length', 0)\n})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Using the `routeHandler` function"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "By specifying a "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeHandler-Function",
            "children": [
              {
                "type": "text",
                "value": "`routeHandler`"
              }
            ]
          },
          {
            "type": "text",
            "value": " function as the last argument to `cy.intercept`, you'll have access to the entire request-response session, enabling you to modify the outgoing request, manipulate the real response, make assertions, etc."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The `routeHandler` takes the incoming HTTP request (`IncomingHTTPRequest`) as the first argument."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/users*', (req) => {\n  /* do something with request and/or response */\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Throughout these examples we will refer to the incoming HTTP request as `req`. Those of you with "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://expressjs.com/",
            "children": [
              {
                "type": "text",
                "value": "Express.js"
              }
            ]
          },
          {
            "type": "text",
            "value": " "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://expressjs.com/en/guide/writing-middleware.html",
            "children": [
              {
                "type": "text",
                "value": "middleware"
              }
            ]
          },
          {
            "type": "text",
            "value": " experience should be familiar with this syntax."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Asserting on a request"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('POST', '/organization', (req) => {\n  expect(req.body).to.include('Acme Company')\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Modifying an outgoing request"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can use the request handler callback to modify the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Intercepted-requests",
            "children": [
              {
                "type": "text",
                "value": "intercepted request object"
              }
            ]
          },
          {
            "type": "text",
            "value": " before it is sent."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// set the request body to something different\n// before it's sent to the destination\ncy.intercept('POST', '/login', (req) => {\n  req.body = 'username=janelane&password=secret123'\n})\n\n// dynamically set the alias\ncy.intercept('POST', '/login', (req) => {\n  req.alias = 'login'\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Changing query parameters with `req.query`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`req.query` holds the request's query parameters as an object. Setting or deleting a property rewrites `req.url`, so the change reaches the server:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/users*', (req) => {\n  // ask for a smaller page than the app does, and drop a debug flag.\n  // Cypress rewrites `req.url` to match.\n  req.query.limit = '2'\n  delete req.query.debug\n}).as('getUsers')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "A request the app sends to `/users?limit=10&debug=true` goes out as `/users?limit=2`."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Adding a header to an outgoing request"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can add a header to an outgoing request, or modify an existing header"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/req-headers', (req) => {\n  req.headers['x-custom-headers'] = 'added by cy.intercept'\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note: the new header will NOT be shown in the browser's Network tab, as the request has already left the browser. You can still confirm the header was added by waiting on the intercept as shown below:"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Waiting on the intercept"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/req-headers', (req) => {\n  req.headers['x-custom-headers'] = 'added by cy.intercept'\n}).as('headers')\n\n// the application makes the call ...\n// confirm the custom header was added\ncy.wait('@headers')\n  .its('request.headers')\n  .should('have.property', 'x-custom-headers', 'added by cy.intercept')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Add, modify or delete a header to all outgoing requests"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can add, modify or delete a header to all outgoing requests using a `beforeEach()` in the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/core-concepts/writing-and-organizing-tests.md#Support-file",
            "children": [
              {
                "type": "text",
                "value": "supportFile"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "beforeEach(() => {\n  cy.intercept(\n    { url: 'http://localhost:3001/**', middleware: true },\n    // Delete 'if-none-match' header from all outgoing requests\n    (req) => delete req.headers['if-none-match']\n  )\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Dynamically stubbing a response"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can use the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Providing-a-stub-response-with-reqreply",
            "children": [
              {
                "type": "text",
                "value": "`req.reply()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " function to dynamically control the response to a request."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/billing', (req) => {\n  // functions on 'req' can be used to\n  // dynamically respond to a request here\n\n  // send the request to the destination server\n  req.reply()\n\n  // respond to the request with a JSON object\n  req.reply({ plan: 'starter' })\n\n  // send the request to the destination server\n  // and intercept the response\n  req.continue((res) => {\n    // 'res' represents the real destination's response\n    // See \"Intercepting a response\" for more details and examples\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Intercepted-requests",
            "children": [
              {
                "type": "text",
                "value": "\"Intercepted requests\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for more information on the `req` object and its properties and methods."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Returning a Promise"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If a Promise is returned from the route callback, it will be awaited before continuing with the request."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('POST', '/login', (req) => {\n  // you could asynchronously fetch test data...\n  return getLoginCredentials().then((credentials) => {\n    // ...and then, use it to supplement the outgoing request\n    req.headers['authorization'] = credentials\n  })\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Passing a request to the next request handler"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Providing-a-stub-response-with-reqreply",
            "children": [
              {
                "type": "text",
                "value": "`req.reply()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " or "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Controlling-the-outbound-request-with-reqcontinue",
            "children": [
              {
                "type": "text",
                "value": "`req.continue()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " is not explicitly called inside of a request handler, requests will pass to the next request handler until none are left."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// you could have a top-level middleware handler that\n// sets an auth token on all requests\n// but remember setting `middleware: true` will\n// cause this to always be called first\ncy.intercept('http://api.company.com/**', { middleware: true }, (req) => {\n  req.headers['authorization'] = `token ${token}`\n})\n\n// and then have another handler that\n// more narrowly asserts on certain requests\ncy.intercept('POST', 'http://api.company.com/widgets', (req) => {\n  expect(req.body).to.include('analytics')\n})\n\n// a POST request to http://api.company.com/widgets would hit both\n// of those callbacks, middleware first, then the request would be\n// sent out with the modified request headers to the\n// real destination"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Disabling logs for a request"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "By default, Cypress logs all requests that match any `cy.intercept()`, as well as all `XMLHttpRequest`s and `fetch` requests. You can use `cy.intercept()` to disable these logs by passing `{ log: false }` in the second parameter:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// disable Cypress's default behavior of logging all XMLHttpRequests and fetches\ncy.intercept({ resourceType: /xhr|fetch/ }, { log: false })"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note: Currently, you can only enable/disable a request's logs when defining the `cy.intercept()`, not inside of an `intercept` callback. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://github.com/cypress-io/cypress/issues/26069",
            "children": [
              {
                "type": "text",
                "value": "#26069"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Intercepting a response"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Inside of a callback passed to `req.continue()`, you can access the destination server's real response."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/integrations', (req) => {\n  // req.continue() with a callback will send the request to\n  // the destination server\n  req.continue((res) => {\n    // 'res' represents the real destination response\n    // you can manipulate 'res' before it's sent to the browser\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Intercepted-responses",
            "children": [
              {
                "type": "text",
                "value": "\"Intercepted responses\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for more information on the `res` object. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Controlling-the-outbound-request-with-reqcontinue",
            "children": [
              {
                "type": "text",
                "value": "\"Controlling the outbound request with `req.continue()`\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for more information about `req.continue()`."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Asserting on a response"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/projects/2', (req) => {\n  req.continue((res) => {\n    expect(res.body).to.include('My Project')\n  })\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Modifying the real server response with `req.continue()`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Change `res` inside the `req.continue()` callback to keep most of the real response while testing an edge case. Here the app still gets the real user, with one field changed:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/api/users/1', (req) => {\n  req.continue((res) => {\n    // keep the real user, but make them an admin\n    res.body.isAdmin = true\n  })\n}).as('getUser')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To change the status code, pass it to "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Ending-the-response-with-ressend",
            "children": [
              {
                "type": "text",
                "value": "`res.send()`"
              }
            ]
          },
          {
            "type": "text",
            "value": ", which merges it with the real response:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/api/users/1', (req) => {\n  req.continue((res) => {\n    // keep the real body, but respond with an error status code\n    res.send({ statusCode: 503 })\n  })\n}).as('getUser')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Returning a Promise"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If a Promise is returned from the route callback, it will be awaited before sending the response to the browser."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/users', (req) => {\n  req.continue((res) => {\n    // the response will not be sent to the browser until\n    // 'waitForSomething()' resolves\n    return waitForSomething()\n  })\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Throttle or delay all incoming responses"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can throttle or delay all incoming responses using a `beforeEach()` in the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/core-concepts/writing-and-organizing-tests.md#Support-file",
            "children": [
              {
                "type": "text",
                "value": "supportFile"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// Throttle API responses to simulate real-world conditions\nbeforeEach(() => {\n  cy.intercept(\n    {\n      url: 'http://localhost:3001/**',\n      middleware: true,\n    },\n    (req) => {\n      req.on('response', (res) => {\n        // Throttle the response to 125 kilobytes per\n        // second (about 1 Mbps) to simulate a mobile\n        // 3G connection\n        res.setThrottle(125)\n      })\n    }\n  )\n})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Request/Response Modification with `routeHandler`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Specify "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeHandler-Function",
            "children": [
              {
                "type": "text",
                "value": "`routeHandler`"
              }
            ]
          },
          {
            "type": "text",
            "value": " as the last argument to modify the outgoing request, stub a response, make assertions, etc."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If a function is passed as the `routeHandler`, it will be called with the intercepted HTTP request:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/api', (req) => {\n  // do something with the intercepted request\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "From here, you can do several things with the intercepted request:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "modify and make assertions on the request like its body, headers, URL, method, etc. ("
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Asserting-on-a-request-1",
                    "children": [
                      {
                        "type": "text",
                        "value": "example"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ")"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "stub out the response without interacting with a real back-end ("
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Controlling-the-response",
                    "children": [
                      {
                        "type": "text",
                        "value": "example"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ")"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "pass the request through to its destination and modify or make assertions on the real response on its way back ("
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Controlling-the-response",
                    "children": [
                      {
                        "type": "text",
                        "value": "example"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ")"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "attach listeners to various events on the request ("
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Controlling-the-response",
                    "children": [
                      {
                        "type": "text",
                        "value": "example"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ")"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Asserting on a request"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can use the request handler callback to make an assertion on the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Intercepted-requests",
            "children": [
              {
                "type": "text",
                "value": "intercepted request object"
              }
            ]
          },
          {
            "type": "text",
            "value": " before it is sent."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// match requests to create a user\ncy.intercept('POST', '/users', (req) => {\n  // make an assertion on the payload contents\n  expect(req.body).to.include('Peter Pan')\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Controlling the outgoing request"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The outgoing request, including its body, headers, etc., can be modified before it's sent."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// modify the request body before it's sent to its destination\ncy.intercept('POST', '/users', (req) => {\n  req.body = {\n    name: 'Peter Pan',\n  }\n})\n\n// add a header to an outgoing request\ncy.intercept('POST', '/users', (req) => {\n  req.headers['x-custom-header'] = 'added by cy.intercept'\n})\n\n// modify an existing header\ncy.intercept('POST', '/users', (req) => {\n  req.headers['authorization'] = 'Basic YWxhZGRpbjpvcGVuc2VzYW1l'\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Verifying the request modification"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('POST', '/users', (req) => {\n  req.headers['x-custom-header'] = 'added by cy.intercept'\n}).as('createUser')\n\ncy.get('button.save').click()\n// you can see the headers in the console output by selecting\n// this line in the command log:\ncy.wait('@createUser')\n  // ...or make an assertion:\n  .its('request.headers')\n  .should('have.property', 'x-custom-header', 'added by cy.intercept')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "In Chrome, Chromium, and Edge the browser sends the modified request, so the modification is reflected in the browser's network traffic (for example, in Chrome DevTools). On the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/native-network-interception.md#Using-the-legacy-network-path",
            "children": [
              {
                "type": "text",
                "value": "legacy network path"
              }
            ]
          },
          {
            "type": "text",
            "value": " the browser logs the request before Cypress modifies it, so the modification does not appear there — verify it from the Cypress command log, or with an assertion on `request.headers` after `cy.wait()`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.intercept()` cannot be debugged using "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/request.md",
            "children": [
              {
                "type": "text",
                "value": "`cy.request()`"
              }
            ]
          },
          {
            "type": "text",
            "value": "! Cypress only intercepts requests made by your front-end application."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Controlling the response"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The intercepted request passed to the route handler (hereafter referred to as `req`, though you can use any name) contains methods to dynamically control the response to a request:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.reply()` - stub out a response requiring no dependency on a real back-end"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.continue()` - modify or make assertions on the real response"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.destroy()` - destroy the request and respond with a network error"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.redirect()` - respond to the request with a redirect to a specified location"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.on()` - modify the response by attaching to events"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Stubbing out a response (`req.reply()`):"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`req.reply()` takes a "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse`"
              }
            ]
          },
          {
            "type": "text",
            "value": " object as the first argument:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// stub out the response without interacting with a real back-end\ncy.intercept('POST', '/users', (req) => {\n  req.reply({\n    headers: {\n      'Set-Cookie': 'newUserName=Peter Pan;',\n    },\n    statusCode: 201,\n    body: {\n      name: 'Peter Pan',\n    },\n    delay: 10, // milliseconds\n    throttleKbps: 125, // kilobytes per second, about 1 Mbps\n    forceNetworkError: false, // default\n  })\n})\n\n// stub out a response body using a fixture\ncy.intercept('GET', '/users', (req) => {\n  req.reply({\n    statusCode: 200, // default\n    fixture: 'users.json',\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse` objects"
              }
            ]
          },
          {
            "type": "text",
            "value": " below for more information."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The `reply` method also supports shorthand to avoid having to specify a `StaticResponse` object:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// equivalent to `req.reply({ body })`\nreq.reply(body)\n\n// equivalent to `req.reply({ body, headers })`\nreq.reply(body, headers)\n\n// equivalent to `req.reply({ statusCode, body, headers})`\nreq.reply(statusCode, body, headers)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note: Calling `reply()` will end the request phase and stop the request from propagating to the next matching request handler in line. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Interception-lifecycle",
            "children": [
              {
                "type": "text",
                "value": "Interception Lifecycle"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See also "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Providing-a-stub-response-with-reqreply",
            "children": [
              {
                "type": "text",
                "value": "Providing a stub response with `req.reply()`"
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Modifying the real response (`continue`):"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The `continue` method accepts a function which is passed an object representing the real response being intercepted on its way back to the client (your front-end application)."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// pass the request through and make an assertion on\n// the real response\ncy.intercept('POST', '/users', (req) => {\n  req.continue((res) => {\n    expect(res.body).to.include('Peter Pan')\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See also "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Controlling-the-outbound-request-with-reqcontinue",
            "children": [
              {
                "type": "text",
                "value": "Controlling the outbound request with `req.continue()`"
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Responding with a network error (`destroy`):"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// dynamically destroy the request and\n// respond with a network error\ncy.intercept('POST', '/users', (req) => {\n  if (mustDestroy(req)) {\n    req.destroy()\n  }\n\n  function mustDestroy(req) {\n    // code that determines whether to force a network error\n    // based on the contents of `req`\n  }\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Responding with a new location (`redirect`):"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// respond to this request with a redirect to a new 'location'\ncy.intercept('GET', '/users', (req) => {\n  // statusCode defaults to `302`\n  req.redirect('/customers', 301)\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Responding by listening to events (`on`):"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('GET', '/users', (req) => {\n  req.on('before:response', (res) => {\n    // do something when the `before:response` event is triggered\n  })\n})\ncy.intercept('POST', '/users', (req) => {\n  req.on('response', (res) => {\n    // do something when the `response` event is triggered\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See example for "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Throttle-or-delay-all-incoming-responses",
            "children": [
              {
                "type": "text",
                "value": "throttling a response"
              }
            ]
          },
          {
            "type": "text",
            "value": ". See more examples of "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Request-events",
            "children": [
              {
                "type": "text",
                "value": "events"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Returning a Promise"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If a Promise is returned from the route callback, it will be awaited before continuing with the request."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('POST', '/users', (req) => {\n  // asynchronously fetch test data\n  return getAuthToken().then((token) => {\n    // ...and apply it to the outgoing request\n    req.headers['Authorization'] = `Basic ${token}`\n  })\n})\n\ncy.intercept('POST', '/users', (req) => {\n  req.continue((res) => {\n    // the response will not be sent to the browser until\n    // `waitForSomething()` resolves:\n    return waitForSomething()\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "A returned Promise must resolve within the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md#Timeouts",
            "children": [
              {
                "type": "text",
                "value": "`defaultCommandTimeout`"
              }
            ]
          },
          {
            "type": "text",
            "value": ", or the test fails with a timeout error. Increase `defaultCommandTimeout` if a callback needs more time."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Stubbing a response with a string"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// requests to create a user will be fulfilled\n// with a body of 'success'\ncy.intercept('POST', '/users', 'success')\n// { body: 'success' }"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Intercepted requests"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If a function is passed as the handler for a `cy.intercept()`, it will be called with the first argument being an object that represents the intercepted HTTP request:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/api', (req) => {\n  // `req` represents the intercepted HTTP request\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "From here, you can do several things with the intercepted request:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "you can modify and assert on the request's properties (body, headers, URL, method...)"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "the request can be sent to the real upstream server"
                  }
                ]
              },
              {
                "type": "list",
                "ordered": false,
                "start": null,
                "spread": false,
                "children": [
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "optionally, you can intercept the response from this"
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "a response can be provided to stub out the request"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "listeners can be attached to various events on the request"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Request object properties"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The request object (`req`) has several properties from the HTTP request itself:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "{\n  /**\n   * The body of the request.\n   * If a JSON Content-Type was used and the body was valid JSON,\n   * this will be an object.\n   * If the body was binary content, this will be a buffer.\n   */\n  body: string | object | any\n  /**\n   * The headers of the request.\n   */\n  headers: { [key: string]: string | string[] }\n  /**\n   * Request HTTP method (GET, POST, ...).\n   */\n  method: string\n  /**\n   * Request URL.\n   */\n  url: string\n  /**\n   * URL query string as object.\n   */\n  query: Record<string, string|number>\n  /**\n   * The HTTP version used in the request. Read only.\n   * Not reported in Chrome, Chromium, or Edge, where the browser negotiates the\n   * protocol with the origin directly and it is not known when the request is\n   * intercepted. Firefox, WebKit, and Electron still report it.\n   */\n  httpVersion?: string\n  /**\n   * The resource type of the request. Read only.\n   */\n  resourceType: 'document' | 'fetch' | 'xhr' | 'websocket' | 'stylesheet'\n              | 'script' | 'image' | 'font' | 'cspviolationreport' | 'ping'\n              | 'manifest' | 'other'\n}"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`req.httpVersion` is not reported in Chrome, Chromium, or Edge, where Cypress intercepts traffic inside the browser and the protocol your application negotiates with your server is not known at the point the request is intercepted. Firefox, WebKit, and Electron route traffic through the Cypress HTTP/1.1 proxy and still report it. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/native-network-interception.md",
            "children": [
              {
                "type": "text",
                "value": "Native network interception"
              }
            ]
          },
          {
            "type": "text",
            "value": " for the other properties this affects and how to write assertions that pass in every browser."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`req` also has some optional properties which can be set to control Cypress-specific behavior:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "{\n  /**\n   * If provided, the number of milliseconds before an upstream\n   * response to this request will time out and cause an error.\n   * By default, `responseTimeout` from config is used.\n   */\n  responseTimeout?: number\n  /**\n   * Set if redirects should be followed when this request is made.\n   * By default, requests will not follow redirects before\n   * yielding the response (the 3xx redirect is yielded).\n   */\n  followRedirect?: boolean\n  /**\n   * If set, `cy.wait` can be used to await the request/response\n   * cycle to complete for this request via `cy.wait('@alias')`.\n   */\n  alias?: string\n}"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Any modifications to the properties of `req` will be persisted to other request handlers, and finally merged into the actual outbound HTTP request."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Controlling the outbound request with `req.continue()`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Calling `req.continue()` without any argument will cause the request to be sent outgoing, and the response will be returned to the browser after any other listeners have been called. For example, the following code modifies a `POST` request and then sends it to the upstream server:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('POST', '/submitStory', (req) => {\n  req.body.storyName = 'some name'\n  // send the modified request and skip any other\n  // matching request handlers\n  req.continue()\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If a function is passed to `req.continue()`, the request will be sent to the real upstream server, and the callback will be called with the response once the response is fully received from the server. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Intercepted-responses",
            "children": [
              {
                "type": "text",
                "value": "\"Intercepted responses\""
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note: calling `req.continue()` will stop the request from propagating to the next matching request handler in line. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Interception-lifecycle",
            "children": [
              {
                "type": "text",
                "value": "\"Interception lifecycle\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for more information."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Providing a stub response with `req.reply()`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The `req.reply()` function can be used to send a stub response for an intercepted request. By passing a string, object, or "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse`"
              }
            ]
          },
          {
            "type": "text",
            "value": " to `req.reply()`, the request can be prevented from reaching the destination server."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "For example, the following code stubs out a JSON response from a request interceptor:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/billing', (req) => {\n  // dynamically get billing plan name at request-time\n  const planName = getPlanName()\n  // this object will automatically be JSON.stringified and\n  // sent as the response\n  req.reply({ plan: planName })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Instead of passing a plain object or string to `req.reply()`, you can also pass a "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse`"
              }
            ]
          },
          {
            "type": "text",
            "value": " object. With a "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse`"
              }
            ]
          },
          {
            "type": "text",
            "value": ", you can force a network error, delay/throttle the response, send a fixture, and more."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "For example, the following code serves a dynamically chosen fixture with a delay of 500ms:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/api/users/*', async (req) => {\n  // asynchronously retrieve fixture filename at request-time\n  const fixtureFilename = await getFixtureFilenameForUrl(req.url)\n  req.reply({\n    fixture: fixtureFilename,\n    delay: 500,\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse` documentation"
              }
            ]
          },
          {
            "type": "text",
            "value": " for more information on stubbing responses in this manner."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "`req.reply()` shorthand"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`req.reply()` also supports shorthand, similar to "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Ending-the-response-with-ressend",
            "children": [
              {
                "type": "text",
                "value": "`res.send()`"
              }
            ]
          },
          {
            "type": "text",
            "value": ", to avoid having to specify a `StaticResponse` object:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// equivalent to `req.reply({ body })`\nreq.reply(body)\n\n// equivalent to `req.reply({ body, headers })`\nreq.reply(body, headers)\n\n// equivalent to `req.reply({ statusCode, body, headers})`\nreq.reply(statusCode, body, headers)"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Convenience functions"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "There are also two convenience functions available on `req`:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "{\n  /**\n   * Destroy the request and respond with a network error.\n   */\n  destroy(): void\n  /**\n   * Respond to this request with a redirect to a new 'location'.\n   * @param statusCode HTTP status code to redirect with. Default: 302\n   */\n  redirect(location: string, statusCode?: number): void\n}"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See examples in the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Controlling-the-response",
            "children": [
              {
                "type": "text",
                "value": "Controlling the response"
              }
            ]
          },
          {
            "type": "text",
            "value": " section"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note: calling `req.reply()` will end the request phase and stop the request from propagating to the next matching request handler in line. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Interception-lifecycle",
            "children": [
              {
                "type": "text",
                "value": "\"Interception lifecycle\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for more information."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Request events"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "For advanced use, several events are available on `req`, that represent different stages of the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Interception-lifecycle",
            "children": [
              {
                "type": "text",
                "value": "Interception lifecycle"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "By calling `req.on`, you can subscribe to different events:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/shop', (req) => {\n  req.on('before:response', (res) => {\n    /**\n     * Emitted before `response` and before any `req.continue`\n     * handlers. Modifications to `res` will be applied to the\n     * incoming response. If a promise is returned, it will be\n     * awaited before processing other event handlers.\n     */\n  })\n\n  req.on('response', (res) => {\n    /**\n     * Emitted after `before:response` and after any\n     * `req.continue` handlers - before the response is sent\n     * to the browser. Modifications to `res` will be applied\n     * to the incoming response. If a promise is returned, it\n     * will be awaited before processing other event handlers.\n     */\n  })\n\n  req.on('after:response', (res) => {\n    /**\n     * Emitted once the response to a request has finished\n     * sending to the browser. Modifications to `res` have no\n     * impact. If a promise is returned, it will be awaited\n     * before processing other event handlers.\n     */\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Intercepted-responses",
            "children": [
              {
                "type": "text",
                "value": "\"Intercepted responses\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for more details on the `res` object yielded by `before:response` and `response`. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Interception-lifecycle",
            "children": [
              {
                "type": "text",
                "value": "\"Interception lifecycle\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for more details on request ordering."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Intercepted responses"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The response can be intercepted in two ways:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "by passing a callback to "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Controlling-the-outbound-request-with-reqcontinue",
                    "children": [
                      {
                        "type": "text",
                        "value": "`req.continue()`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " within a request handler"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "by listening for the `before:response` or `response` request events (see "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Request-events",
                    "children": [
                      {
                        "type": "text",
                        "value": "\"Request events\""
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ")"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Each one runs at a different point in the response:"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Hook"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Runs"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Changes to `res` reach the browser"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.on('before:response')`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "First, before any `req.continue()` callback"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Yes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.continue(callback)`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "After `before:response`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Yes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.on('response')`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "After the `req.continue()` callback, before the browser gets the response"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Yes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`req.on('after:response')`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "After the browser has received the response"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "No"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The response object, `res`, will be passed as the first argument to the handler function:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/url', (req) => {\n  req.on('before:response', (res) => {\n    // this will be called before any `req.continue` or\n    // `response` handlers\n  })\n\n  req.continue((res) => {\n    // this will be called after all `before:response`\n    // handlers and before any `response` handlers\n    // by calling `req.continue`, we signal that this\n    // request handler will be the last one, and that\n    // the request should be sent outgoing at this point.\n    // for that reason, there can only be one\n    // `req.continue` handler per request.\n  })\n\n  req.on('response', (res) => {\n    // this will be called after all `before:response`\n    // handlers and after the `req.continue` handler\n    // but before the response is sent to the browser\n  })\n})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Response object properties"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The response object (`res`) yielded to response handlers has several properties from the HTTP response itself. All of the following properties on `res` can be modified:"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Property"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Description"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "body"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "response body (`object`, `string`, `ArrayBuffer`)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "headers"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "response headers (`object`)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "statusCode"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "response status code (`number`)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "statusMessage"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "response status message (`string`)"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`res.statusMessage` is an empty string when the response reached the browser over a protocol that carries no reason phrase. HTTP/2 and HTTP/3 do not carry one, so a response your server delivered over either reports `''`. An HTTP/1.1 response reports the phrase your server sent, which may itself be empty. Prefer `res.statusCode`, which is always reported, and treat the phrase for a standard code as redundant with it."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note about `body`: If the response header contains `Content-Type: application/json` and the body contains valid JSON, this will be an `object`. And if the body contains binary content, this will be a buffer."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Cypress relies on the `Content-Type: application/json` header to decide whether to parse the body as JSON. If that header is absent, the body is yielded as a `string` even when it contains JSON. This commonly happens with responses that omit a `Content-Type` header. For example, a `304 Not Modified` response, which "
          },
          {
            "type": "link",
            "title": null,
            "url": "https://datatracker.ietf.org/doc/html/rfc7232#section-4.1",
            "children": [
              {
                "type": "text",
                "value": "per RFC 7232"
              }
            ]
          },
          {
            "type": "text",
            "value": " is not expected to include representation metadata such as `Content-Type`, or a `301` redirect. When asserting on `response.body` for these responses, either assert against the string value or parse it yourself with `JSON.parse()`:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.wait('@getResource').then(({ response }) => {\n  // when no `Content-Type: application/json` header is present,\n  // `response.body` is a string and must be parsed before\n  // asserting on its properties\n  const body =\n    typeof response.body === 'string'\n      ? JSON.parse(response.body)\n      : response.body\n\n  expect(body).to.have.property('id')\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`res` also has some optional properties which can be set to control Cypress-specific behavior:"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Property"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Description"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "throttleKbps"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Maximum data transfer rate of the response (kilobytes/second)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "delay"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Minimum network latency or delay to add to the response time (milliseconds)"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Any modifications to the properties of `res` will be persisted to other response handlers, and finally merged into the actual incoming HTTP response."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Ending the response with `res.send()`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To end the response phase of the request, call `res.send()`. Optionally, you can pass a "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse`"
              }
            ]
          },
          {
            "type": "text",
            "value": " to `res.send()`, to be merged with the actual response."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When `res.send()` is called, the response phase will end immediately and no other response handlers will be called for the current request. Here is an example of how `res.send()` could be used:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/notification', (req) => {\n  req.continue((res) => {\n    if (res.body.status === 'failed') {\n      // sends a fixture body instead of the existing 'res.body'\n      res.send({ fixture: 'success.json' })\n    }\n  })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See the "
          },
          {
            "type": "link",
            "title": null,
            "url": "#StaticResponse-objects",
            "children": [
              {
                "type": "text",
                "value": "`StaticResponse` documentation"
              }
            ]
          },
          {
            "type": "text",
            "value": " for more information on the format."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "`res.send()` shorthand"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`res.send()` also supports shorthand, similar to "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Providing-a-stub-response-with-reqreply",
            "children": [
              {
                "type": "text",
                "value": "`req.reply()`"
              }
            ]
          },
          {
            "type": "text",
            "value": ", to avoid having to specify a `StaticResponse` object:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// equivalent to `res.send({ body })`\nres.send(body)\n\n// equivalent to `res.send({ body, headers })`\nres.send(body, headers)\n\n// equivalent to `res.send({ statusCode, body, headers})`\nres.send(statusCode, body, headers)"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Convenience functions"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "There are also two convenience functions available on `res`:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "{\n  /**\n   * Wait for 'delay' milliseconds before sending the\n   * response to the client.\n   */\n  setDelay: (delay: number) => IncomingHttpResponse\n  /**\n   * Serve the response at 'throttleKbps' kilobytes per second.\n   */\n  setThrottle: (throttleKbps: number) => IncomingHttpResponse\n}"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note: calling `res.send()` will end the response phase and stop the response from propagating to the next matching response handler in line. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Interception-lifecycle",
            "children": [
              {
                "type": "text",
                "value": "\"Interception lifecycle\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for more information."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "`StaticResponse` objects"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "A `StaticResponse` represents a "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Stubbing-a-response",
            "children": [
              {
                "type": "text",
                "value": "statically defined response (stub)"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The following properties are available on `StaticResponse`."
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Option"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Description"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "statusCode"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "HTTP response status code (default: `200`)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "headers"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "HTTP response headers"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "body"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Serve a static response body (`object`, `string`, `ArrayBuffer`) (when `fixture` is omitted)."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "fixture"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Serve a fixture as the HTTP response body (allowed when `body` is omitted). Read the contents with an encoding other than the "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/fixture.md#How-Cypress-chooses-a-fixtures-encoding",
                    "children": [
                      {
                        "type": "text",
                        "value": "default for the file type"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ", pass the fixture like `path,encoding`."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "forceNetworkError"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Force an error by destroying the browser connection. Can't be combined with `body`, `statusCode`, or `headers`."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "delay"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Minimum network latency or delay to add to the response time (milliseconds)"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "throttleKbps"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Maximum data transfer rate of the response (kilobytes/second)"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note: All properties are optional."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can supply a `StaticResponse` to Cypress in 3 ways:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "To `cy.intercept()` as "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#staticResponse-StaticResponse",
                    "children": [
                      {
                        "type": "text",
                        "value": "`an argument`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ", to stub a response to a route: `cy.intercept('/url', staticResponse)`"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "To "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Providing-a-stub-response-with-reqreply",
                    "children": [
                      {
                        "type": "text",
                        "value": "`req.reply()`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ", to stub a response from a request handler: `req.reply(staticResponse)`"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "To "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Ending-the-response-with-ressend",
                    "children": [
                      {
                        "type": "text",
                        "value": "`res.send()`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ", to stub a response from a response handler: `res.send(staticResponse)`"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#With-a-StaticResponse-object",
            "children": [
              {
                "type": "text",
                "value": "\"Stubbing a response with a `StaticResponse` object\""
              }
            ]
          },
          {
            "type": "text",
            "value": " for examples of stubbing with `cy.intercept()`."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Interception lifecycle"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The lifecycle of a `cy.intercept()` interception begins when an HTTP request is sent from your app that matches one or more registered `cy.intercept()` routes. From there, each interception has two phases: request and response."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.intercept()` runs the routes that match a request in this order:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": true,
        "start": 1,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Routes defined with `{ middleware: true }`, in the order you define them."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "All other routes, starting with the one you defined last."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "It stops at the first route that has a static response or calls `req.reply()` or `req.continue()`. Routes after it never see the request."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "In practice, this means a route you define later overrides an earlier one, and middleware always runs first:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "beforeEach(() => {\n  // runs first on every request, because it's middleware\n  cy.intercept('/api/*', { middleware: true }, (req) => {\n    req.headers['authorization'] = 'Bearer test-token'\n  })\n\n  // the default for most tests\n  cy.intercept('GET', '/api/users', { fixture: 'users.json' })\n})\n\nit('shows an empty state', () => {\n  // defined last, so it runs before the fixture route and responds,\n  // and the fixture route never sees the request\n  cy.intercept('GET', '/api/users', { body: [] })\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Overriding-an-intercept-in-a-single-test",
            "children": [
              {
                "type": "text",
                "value": "Overriding an intercept in a single test"
              }
            ]
          },
          {
            "type": "text",
            "value": " for a complete example."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Request phase"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The following steps are used to handle the request phase."
          }
        ]
      },
      {
        "type": "list",
        "ordered": true,
        "start": 1,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Start with the first matching route, in the order described above (middleware first, then all other routes starting with the last defined)."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Was a handler (body, "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#StaticResponse-objects",
                    "children": [
                      {
                        "type": "text",
                        "value": "`StaticResponse`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ", or function) supplied to `cy.intercept()`? If not, continue to step 7."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "If the handler was a body or "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#StaticResponse-objects",
                    "children": [
                      {
                        "type": "text",
                        "value": "`StaticResponse`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ", immediately end the request with that response."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "If the handler was a function, call the function with `req`, the incoming request, as the first argument. See "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Intercepted-requests",
                    "children": [
                      {
                        "type": "text",
                        "value": "\"Intercepted requests\""
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " for more information on the `req` object."
                  }
                ]
              },
              {
                "type": "list",
                "ordered": false,
                "start": null,
                "spread": false,
                "children": [
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "#Providing-a-stub-response-with-reqreply",
                            "children": [
                              {
                                "type": "text",
                                "value": "`req.reply()`"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " is called, immediately end the request phase with the provided response. See "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "#Providing-a-stub-response-with-reqreply",
                            "children": [
                              {
                                "type": "text",
                                "value": "\"Providing a stub response with `req.reply()`\""
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": "."
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "#Controlling-the-outbound-request-with-reqcontinue",
                            "children": [
                              {
                                "type": "text",
                                "value": "`req.continue()`"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " is called, immediately end the request phase, and send the request to the destination server. If a callback is provided to "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "#Controlling-the-outbound-request-with-reqcontinue",
                            "children": [
                              {
                                "type": "text",
                                "value": "`req.continue()`"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": ", it will be called during the "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "#Response-phase",
                            "children": [
                              {
                                "type": "text",
                                "value": "response phase"
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "If the handler returned a Promise, wait for the Promise to resolve."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Merge any modifications to the request object with the real request."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "If there is another matching `cy.intercept()`, return to step 2 and continue following steps with that route."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Send the request outgoing to the destination server and end the request phase. The "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Response-phase",
                    "children": [
                      {
                        "type": "text",
                        "value": "response phase"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " will begin once a response is received."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Response phase"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Once the HTTP response is received from the upstream server, the following steps are applied:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": true,
        "start": 1,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Get a list of registered `before:response` event listeners."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "For each `before:response` listener (if any), call it with the "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Intercepted-responses",
                    "children": [
                      {
                        "type": "text",
                        "value": "`res`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " object."
                  }
                ]
              },
              {
                "type": "list",
                "ordered": false,
                "start": null,
                "spread": false,
                "children": [
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "#Ending-the-response-with-ressend",
                            "children": [
                              {
                                "type": "text",
                                "value": "`res.send()`"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " is called, end the response phase and merge any passed arguments with the response."
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If a Promise is returned, await it. Merge any modified response properties with the real response."
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "If a `req.continue()` with callback is declared for this route, call the callback with the "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Intercepted-responses",
                    "children": [
                      {
                        "type": "text",
                        "value": "`res`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " object."
                  }
                ]
              },
              {
                "type": "list",
                "ordered": false,
                "start": null,
                "spread": false,
                "children": [
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "#Ending-the-response-with-ressend",
                            "children": [
                              {
                                "type": "text",
                                "value": "`res.send()`"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " is called, end the response phase and merge any passed arguments with the response."
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If a Promise is returned, await it. Merge any modified response properties with the real response."
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Get a list of registered `response` event listeners."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "For each `response` listener (if any), call it with the "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Intercepted-responses",
                    "children": [
                      {
                        "type": "text",
                        "value": "`res`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " object."
                  }
                ]
              },
              {
                "type": "list",
                "ordered": false,
                "start": null,
                "spread": false,
                "children": [
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If "
                          },
                          {
                            "type": "link",
                            "title": null,
                            "url": "#Ending-the-response-with-ressend",
                            "children": [
                              {
                                "type": "text",
                                "value": "`res.send()`"
                              }
                            ]
                          },
                          {
                            "type": "text",
                            "value": " is called, end the response phase and merge any passed arguments with the response."
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If a Promise is returned, await it. Merge any modified response properties with the real response."
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Send the response to the browser."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Once the response is complete, get a list of registered `after:response` event listeners."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "For each `after:response` listener (if any), call it with the "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Intercepted-responses",
                    "children": [
                      {
                        "type": "text",
                        "value": "`res`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " object (minus `res.send`)"
                  }
                ]
              },
              {
                "type": "list",
                "ordered": false,
                "start": null,
                "spread": false,
                "children": [
                  {
                    "type": "listItem",
                    "spread": false,
                    "checked": null,
                    "children": [
                      {
                        "type": "paragraph",
                        "children": [
                          {
                            "type": "text",
                            "value": "If a Promise is returned, await it."
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "End the response phase."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Glob Pattern Matching URLs"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Matching-url",
            "children": [
              {
                "type": "text",
                "value": "matching a URL"
              }
            ]
          },
          {
            "type": "text",
            "value": ", providing an exact URL to match can be too restrictive. For example, what if you wanted to run your tests on a different host?"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// match any request that exactly matches the URL\ncy.intercept('https://prod.cypress.io/users')\n// matches this: https://prod.cypress.io/users\n// ...but not this: https://staging.cypress.io/users\n// ...or this: http://localhost/users"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Glob pattern matching provides the necessary flexibility:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/users')\n// matches all of these:\n//   https://prod.cypress.io/users\n//   https://staging.cypress.io/users\n//   http://localhost/users\n\ncy.intercept('/users\\\\?_limit=+(3|5)')\n// matches all of these:\n//   https://prod.cypress.io/users?_limit=3\n//   http://localhost/users?_limit=5"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "In minimatch glob syntax, `?` is a wildcard that matches any single character — it does not represent a literal `?`. To match a literal question mark (such as the `?` that begins a URL query string), escape it with a backslash: use `\\\\?` in your JavaScript string so that minimatch receives the pattern character `\\?`."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// INCORRECT – the unescaped ? is a wildcard matching any single character\ncy.intercept('/users?_limit=*')\n\n// CORRECT – \\\\? in the JS string sends \\? to minimatch, matching a literal ?\ncy.intercept('/users\\\\?_limit=*')"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Cypress.minimatch"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Under the hood, `cy.intercept` uses the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/utilities/minimatch.md",
            "children": [
              {
                "type": "text",
                "value": "minimatch"
              }
            ]
          },
          {
            "type": "text",
            "value": " library with the `{ matchBase: true }` option applied for glob matching and provides access to it via the `Cypress` global. This enables you to test your pattern in your spec or in the Cypress browser console."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can invoke the `Cypress.minimatch` with just two arguments - the URL (`string`) and the pattern (`string`), respectively - and if it yields `true`, then you have a match!"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.intercept()` matches patterns against the full request URL (including protocol and hostname). If the full URL does not match, it also tries matching against the URL path — everything after the hostname, including any query string — as a fallback."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Because of this fallback, path-only patterns like `/api/users*` work with `cy.intercept()` even though they omit the hostname. However, when verifying such a pattern with `Cypress.minimatch()`, pass just the path — not the full URL — to replicate the fallback behavior accurately:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// path-only pattern: test with the path\nCypress.minimatch('/api/users?page=1', '/api/users*', { matchBase: true }) // true\n\n// full-URL pattern (** absorbs the hostname): test with the full URL\nCypress.minimatch('http://localhost/api/users?page=1', '**/api/users*') // true"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Passing the full URL to `Cypress.minimatch()` with a path-only pattern may return `false` even though `cy.intercept()` would match via its path fallback."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "expect(\n  Cypress.minimatch(\n    'http://localhost/users?_limit=3',\n    '**/users\\\\?_limit=+(3|5)'\n  )\n).to.be.true\nexpect(\n  Cypress.minimatch('/users?_limit=5', '/users\\\\?_limit=+(3|5)', {\n    matchBase: true,\n  })\n).to.be.true\nexpect(\n  Cypress.minimatch(\n    'http://localhost/users?_limit=7',\n    '**/users\\\\?_limit=+(3|5)'\n  )\n).to.be.false"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When intercepting URLs that have complex or encoded query strings, using a URL glob for the entire URL (path + query string) can be error-prone. The `pathname` and `query` "
          },
          {
            "type": "link",
            "title": null,
            "url": "#routeMatcher-RouteMatcher",
            "children": [
              {
                "type": "text",
                "value": "routeMatcher"
              }
            ]
          },
          {
            "type": "text",
            "value": " properties provide a more reliable alternative:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// Instead of matching the full path + query string with a glob:\ncy.intercept('/api/v3/upload_status/**/process**')\n\n// Match just the path, and optionally assert the query separately:\ncy.intercept({\n  pathname: '/api/v3/upload_status/**/process',\n})\n\n// Or pin specific query parameter values:\ncy.intercept({\n  pathname: '/api/v3/upload_status/**/process',\n  query: { json: '{\"count\":12,\"offset\":0}' },\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`pathname` never includes the query string, so encoded or complex query parameters cannot interfere with path-segment glob matching."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "minimatch options"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can also pass in options (`object`) as the third argument, one of which is `debug` which if set to `true`, will yield verbose output that could help you understand why your pattern isn't working as you expect:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.minimatch(\n  'http://localhost/users?_limit=3',\n  '**/users\\\\?_limit=+(3|5)',\n  {\n    debug: true,\n  }\n)\n// true (plus debug messages)"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "`cy.intercept()` and test performance"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Intercept only the requests your test needs. A catch-all route such as `cy.intercept('*')` matches every request the page makes, including images, scripts, fonts, and third-party calls. Cypress records and logs every request a route matches, and a route with a handler function holds each request until the handler finishes. Scope the route to the endpoint instead:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// 🚫 matches every request the page makes\ncy.intercept('*').as('anyRequest')\n\n// ✅ matches only the requests the test waits on\ncy.intercept('GET', '/api/users*').as('getUsers')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Third-party services such as analytics and error monitoring (Sentry, for example) usually don't need to run in tests. Add their hosts to "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md#blockHosts",
            "children": [
              {
                "type": "text",
                "value": "`blockHosts`"
              }
            ]
          },
          {
            "type": "text",
            "value": ", and Cypress answers those requests with a `503` instead of sending them:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.js"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.ts"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const { defineConfig } = require('cypress')\n\nmodule.exports = defineConfig({\n  blockHosts: ['*.sentry.io'],\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "import { defineConfig } from 'cypress'\n\nexport default defineConfig({\n  blockHosts: ['*.sentry.io'],\n})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/test-performance.md#Intercept-only-the-requests-you-need",
            "children": [
              {
                "type": "text",
                "value": "Test Performance"
              }
            ]
          },
          {
            "type": "text",
            "value": " for more ways to speed up tests that use the network."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Troubleshooting a `cy.intercept()` route that doesn't match"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When an intercept never fires, the Command Log shows it. In the Routes panel, the route's # column shows `-` because it hasn't matched a request, and the request your app sent appears without an alias badge:"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Here the app requested `/api/users?page=1`, but the route's pattern has no wildcard for the query string:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// the app requests /api/users?page=1\ncy.intercept('GET', '/api/users').as('getUsers') // never matches"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Either pattern below matches it:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// match any query string\ncy.intercept('GET', '/api/users*').as('getUsers')\n\n// or match the path and ignore the query string\ncy.intercept({ method: 'GET', pathname: '/api/users' }).as('getUsers')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When a route doesn't match, check these:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "The pattern covers the whole URL. A glob must match the full URL or path, including any query string. Test it with "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Cypressminimatch",
                    "children": [
                      {
                        "type": "text",
                        "value": "`Cypress.minimatch()`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ", or match on `pathname` instead."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "The method matches. `cy.intercept('GET', …)` never matches a `POST`."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "The intercept is defined before the request. A route only sees requests sent after it's defined, so call `cy.intercept()` before the `cy.visit()` or action that triggers the request."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "The request isn't served from the cache. Cached responses never reach the network. See "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#cyintercept-and-request-caching",
                    "children": [
                      {
                        "type": "text",
                        "value": "`cy.intercept()` and request caching"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": "."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Your app sent the request. `cy.intercept()` doesn't see requests made by "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/request.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`cy.request()`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": "."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "`cy.intercept()` and request caching"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.intercept()` intercepts requests at the network layer. This can cause confusion when trying to intercept a request that has already been cached by the browser. If a request is served from the browser cache, it will never hit the network layer, and `cy.intercept()` will never fire."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To see if this is affecting your app, open the Network tab in Chrome DevTools and check the Size column. A request served from the cache shows `(memory cache)` or `(disk cache)` there. It never reaches the network, so `cy.intercept()` can't intercept it. In this example, only `users` and the page itself went over the network:"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If you would like to intercept resources that normally send cache headers, here are some workarounds:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": true,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Turn off cache headers on your development server when in testing mode."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": true,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Disable caching on responses by adding a top-level `cy.intercept()` that removes cache headers from desired requests. For example:"
                  }
                ]
              },
              {
                "type": "code",
                "lang": null,
                "meta": null,
                "value": "beforeEach(() => {\n  cy.intercept(\n    'https://api.example.com/**/*',\n    { middleware: true },\n    (req) => {\n      req.on('before:response', (res) => {\n        // force all API responses to not be cached\n        res.headers['cache-control'] = 'no-store'\n      })\n    }\n  )\n})"
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Chromium-family browsers only: Use `remote:debugger:protocol` to disable cache entirely. For more information, see "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://github.com/cypress-io/cypress/issues/14459#issuecomment-768616195",
                    "children": [
                      {
                        "type": "text",
                        "value": "this comment on issue #14459"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": "."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "`cy.intercept()` and CORS preflight requests"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Before some cross-origin requests, such as a `POST` with a JSON body, the browser sends an `OPTIONS` preflight request to ask the other origin for permission. When a `cy.intercept()` route matches the request's URL, Cypress answers that preflight for you and allows the request. A stub for another origin works without a real server behind it and without adding CORS headers to the stub:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// the app, served from its own origin, POSTs JSON to another origin,\n// so the browser sends an OPTIONS preflight first\ncy.intercept('POST', 'https://api.example.com/orders', {\n  statusCode: 201,\n  body: { id: 1 },\n}).as('createOrder')\n\ncy.get('[data-cy=\"place-order\"]').click()\ncy.wait('@createOrder').its('response.statusCode').should('eq', 201)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To test how your app handles the preflight itself, such as a rejected one, add a route that matches the `OPTIONS` method. Cypress then passes the preflight to your routes instead of answering it."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Command Log"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Routes Instrument Panel"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When you create `cy.intercept()` rules, Cypress will display a new Instrument called Routes."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/accounts*').as('accountsGet')\ncy.intercept('/company', { companyId: 1 }).as('companyGet')\ncy.intercept('/teams*', [{ teamId: 2 }]).as('teamsGet')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "It will list the routing table in the Instrument Panel, including the `method`, `RouteMatcher`, if the route is stubbed, any alias, and number of matched requests:"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When HTTP requests are made, Cypress logs them in the Command Log. A request that matched a `cy.intercept()` shows a badge on the right-hand side with the route's alias, or \"no alias\" when the route has none:"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The circular indicator is filled if the request went to the destination server, and outlined if the request was stubbed with a response. It's green for a `2xx` or `3xx` status and red for any other status."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Hover over a badge to see which `cy.intercept()` routes the request matched, and whether it reached the server:"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Clicking on a request that matched a `cy.intercept()` will print additional information about the request and response to the console:"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/network-requests.md#Command-Log",
            "children": [
              {
                "type": "text",
                "value": "Read more about request logging in Cypress."
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "History"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Version"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Changes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#15-20-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "15.20.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Added support for `QUERY` method."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#14-0-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "14.0.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Deprecated `resourceType` property"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#12-2-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "12.2.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Added `resourceType` property to `req` and `RouteMatcher`."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#7-6-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "7.6.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Added `query` option to `req` (The incoming request object yielded to request handler functions)."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#7-0-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "7.0.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Removed `matchUrlAgainstPath` option from `RouteMatcher`, reversed handler ordering, added request events, removed substring URL matching, removed `cy.route2` alias, added `middleware` RouteMatcher option, renamed `res.delay()` to `res.setDelay()` and `res.throttle()` to `res.setThrottle()`."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#6-4-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "6.4.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Renamed `delayMs` property to `delay` (backwards-compatible)."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#6-2-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "6.2.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Added `matchUrlAgainstPath` option to `RouteMatcher`."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#6-0-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "6.0.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Renamed `cy.route2()` to `cy.intercept()`."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#6-0-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "6.0.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Removed `experimentalNetworkStubbing` option and made it the default behavior."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#5-1-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "5.1.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Added experimental `cy.route2()` command under `experimentalNetworkStubbing` option."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "See also"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/as.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`.as()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/wait.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`cy.wait()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/guides/network-requests.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Network Requests Guide"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://github.com/cypress-io/cypress-example-recipes#stubbing-and-spying",
                    "children": [
                      {
                        "type": "text",
                        "value": "Cypress Example Recipes"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://github.com/cypress-io/cypress-example-kitchensink/blob/master/cypress/e2e/2-advanced-examples/network_requests.cy.js",
                    "children": [
                      {
                        "type": "text",
                        "value": "Kitchen Sink Examples"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 12223
}