Recommended Free Tools
Use cy.intercept() to watch or control HTTP requests made by the application in a Cypress test. Register the route before the action that sends the request, give it an alias, trigger the action, then use cy.wait('@alias') to inspect the request and response. Leave out a response handler to spy on real traffic; provide a response or call req.reply() to stub it.
Write the basic intercept-and-wait test
This example waits for the users request triggered by visiting the page, then checks the response status:
cy.intercept('GET', '/api/users').as('getUsers')
cy.visit('/users')
cy.wait('@getUsers').its('response.statusCode').should('eq', 200)
The order matters: define the intercept before cy.visit() or other action that causes the request. Otherwise the application may send it before Cypress has registered the route. Adapt the method, URL, page action, and assertion to your application. See the Cypress cy.intercept() API reference and network requests guide.
Choose what the intercept should do
Spy on the real request
An intercept with no response handler observes matching application traffic and lets the request continue to the real server. Alias it and wait for it when you need to assert that the application sent the request or received the server response.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
cy.intercept('POST', '/api/orders').as('createOrder')
cy.get('[data-cy=submit-order]').click()
cy.wait('@createOrder').then(({ request, response }) => {
expect(request.body).to.have.property('items')
expect(response.statusCode).to.eq(201)
})
Stub a response
Pass a string, body, fixture, or StaticResponse as the third argument to return controlled data to the application. A static response can set fields such as status code, headers, body, delay, throttling, or a forced network error.
cy.intercept('GET', '/api/users', {
statusCode: 200,
body: [{ id: 7, name: 'Avery' }]
}).as('getUsers')
cy.visit('/users')
cy.wait('@getUsers')
cy.contains('Avery').should('be.visible')
Stubbing makes the response predictable and lets a test cover states that are difficult to produce on demand. It does not establish that the real server returns the stubbed data or that the endpoint works; keep appropriate end-to-end coverage against real responses. Cypress discusses this trade-off in its network requests guide.
Build a response dynamically
Use a route handler when the response depends on the request. Call req.reply() with the response you want the application to receive.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
cy.intercept('POST', '/api/search', (req) => {
if (req.body.term === 'known item') {
req.reply({ statusCode: 200, body: { results: ['Known Item'] } })
} else {
req.reply({ statusCode: 200, body: { results: [] } })
}
}).as('search')
Inspect or modify a real exchange
Change request properties in the handler if needed, then call req.continue() to send the request to the server. Its optional callback can inspect the real response before it reaches the application. Calling req.reply() or req.continue() ends propagation to later matching handlers.
cy.intercept('GET', '/api/profile', (req) => {
req.headers['x-test-mode'] = 'enabled'
req.continue((res) => {
expect(res.statusCode).to.eq(200)
})
}).as('profile')
Match the request you intend to intercept
cy.intercept() accepts a URL alone, a method and URL, or a RouteMatcher object. URL patterns can be exact strings, glob patterns, or regular expressions. When a string matcher is used, Cypress applies minimatch with matchBase: true. If you omit the method, the route can match requests using any HTTP method, so specify one when method ambiguity matters.
Use a RouteMatcher for several constraints
Matcher properties include method, hostname, path, pathname, query, headers, port, https, times, and middleware. Every property you set must match.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
cy.intercept({
method: 'GET',
pathname: '/api/users',
query: { role: 'admin' }
}).as('adminUsers')
Use pathname when matching the path without query parameters; use path when the query string is part of the path being matched. Choose a glob or regular expression when the URL varies, such as across IDs or query values.
Handle repeated query parameters
A query matcher cannot compare all repeated values through one string. For repeated array-style parameters, match the URL with a regular expression or inspect all values in a route handler using URLSearchParams.getAll().
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →cy.intercept('GET', //api/search?.*/, (req) => {
const url = new URL(req.url)
const tags = url.searchParams.getAll('tag')
expect(tags).to.include('cypress')
}).as('tagSearch')
Wait for the network event and assert on it
Call .as('name') on a route, then use cy.wait('@name') after the action that should trigger it. The wait yields an interception object containing request and response information. Assert only on the details the test needs, such as the request URL, body, or headers and the response status or body.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
cy.intercept('POST', '/api/orders').as('createOrder')
cy.get('[data-cy=submit-order]').click()
cy.wait('@createOrder').then((interception) => {
expect(interception.request.body.items).to.have.length(1)
expect(interception.response.statusCode).to.eq(201)
})
For an action that triggers several independently relevant requests, Cypress also supports passing an array of aliases to cy.wait(). Prefer waiting on the request or requests the test actually depends on rather than sleeping for an arbitrary duration: the alias synchronizes the test with the network event itself.
Understand scope, cleanup, and route ordering
Only front-end application traffic is intercepted
Cypress states, “Cypress only intercepts requests made by your front-end application.” A request made with cy.request() originates in Cypress’s Node process, not as browser application traffic, so cy.intercept() does not observe it. For the distinction, see the Cypress FAQ.
Routes are reset between tests
Cypress clears intercept routes before each test. Register the routes within each test that needs them, or in a setup hook that runs for each such test; do not rely on an intercept remaining active from a previous test.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Overlapping handlers have an order
Ordinary matching route handlers are processed in reverse definition order. Routes configured with middleware: true run first. If several handlers match the same request, account for this order—particularly when a handler calls req.reply() or req.continue(), which stops further propagation.
Troubleshoot an intercept that does not fire
- The request happened before registration: move
cy.intercept()before the visit, click, or other action that triggers it. - The method or URL does not match: check the actual method and full request URL in the Cypress Command Log, then adjust the matcher. Remember that omitting a method matches all methods, and that every configured RouteMatcher property must match.
- The call came from
cy.request(): this command sends traffic from Cypress’s Node process, outside the browser-application traffic thatcy.intercept()observes. Test the browser request instead, or assert on thecy.request()result directly. - A later handler appears to be ignored: inspect overlapping routes and their reverse definition order; check whether an earlier-in-execution middleware route runs first or a handler ends propagation with
req.reply()orreq.continue(). - The route worked in one test but not the next: intercepts are cleared before each test, so register the route again for each test that needs it.
Use the Cypress Command Log’s Routes display to inspect which routes were registered. Cypress documents changes to its native network interception behavior across versions; the guide notes that before Cypress 16, application requests used the legacy network path. Check the native network interception guide for version-specific details. The cited documentation does not establish a complete browser compatibility matrix, so verify behavior against the Cypress version and browser combination used by your project.
Or skip the browser setup
cy.intercept() is for controlling or observing application requests in tests; it is not a website screenshot tool. If your separate task is to capture a rendered page, ScreenshotNeo provides a screenshot API and MCP server. One GET request can return an image or PDF; for example, this cURL request saves a WebP capture:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for request options. It removes known cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server gives AI agents screenshot, page-info, and PDF-capture tools. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for free ScreenshotNeo access.
Frequently Asked Questions
Can I use cy.intercept() to mock a failed network request?
Yes. A static response can force a network error; see the API reference for the supported response controls.
Can one cy.intercept() match more than one URL?
A glob or regular-expression URL matcher can cover a family of URLs; use a RouteMatcher when you need multiple constraints on a request.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

