Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteUse cy.intercept() to watch or control a browser request, give the route an alias, trigger the action, then wait for that alias and assert the interception’s request or response. Register the intercept before the action that sends the request. If the response should change the page, assert the rendered result too.
The basic pattern: intercept, trigger, wait, assert
This example observes a real backend request. The form submission must cause the browser to send a matching POST request to /api/users.
cy.intercept('POST', '/api/users').as('createUser')
cy.get('form').submit()
cy.wait('@createUser').then(({ request, response }) => {
expect(request.body).to.have.property('name', 'Ada Lovelace')
expect(response.statusCode).to.equal(201)
})
cy.contains('User created')
The alias wait yields the completed interception, including its request and, when a response is received, response details. Assertions on the request show what the application sent; response assertions show what came back. The final UI assertion checks the user-visible result rather than stopping at transport behavior. See the Cypress cy.intercept() API and cy.wait() API.
Choose whether to observe the server or stub its response
cy.intercept() can spy on a request while it goes to the real server, or stub the response with a controlled fixture or body. Choose according to what the test needs to establish.
#1 Best Overall
| Approach | What it verifies | Trade-off |
|---|---|---|
| Spy; allow the real server response | The browser application emits the request and participates in the real request/response path. | Needs a suitable test backend and data setup; backend variability can affect the test. |
| Stub; return a controlled response | The request construction and the UI’s handling of a known response. | Does not establish that the real backend returns that response. |
These approaches complement each other. Cypress’s Real World App says its end-to-end tests predominantly use server responses and stub on a few occasions for convenient edge cases; that is an example, not a rule for every suite. Use a spy for behavior that depends on integration with the service. Use a stub when the test needs a deterministic edge case or should isolate the UI from backend variability. The Cypress network requests guide describes both modes.
Match the request and assert the right fields
Register the route before the page visit or UI action that triggers it. Give it a descriptive alias, then wait for that alias. Match by URL, method plus URL, or a route matcher; Cypress supports exact URLs, glob patterns, and regular expressions. If you omit the method, the route can match every HTTP method, which may be broader than intended. See the route-matching options.
Rank #2
For example, if the query string is variable, a glob pattern can match the relevant endpoint:
cy.intercept('GET', '**/search*').as('search')
cy.get('[data-cy=search]').type('Book{enter}')
cy.wait('@search')
.its('request.url')
.should('include', '/search?query=Book')
Use a method-and-path match when those are stable, and use a route matcher or pattern when the URL has variable parts. Keep the match narrow enough to identify the request under test. Common interception fields include:
Rank #3
request.urlandrequest.methodfor the destination and HTTP verb.request.bodyandrequest.headersfor submitted data and request headers.response.statusCode,response.bodyandresponse.headersfor a received response.errorwhen intentionally testing a network error.
A focused assertion can use its(), such as cy.wait('@alias').its('response.statusCode').should('eq', 200). For several related assertions, use a callback:
cy.wait('@createUser').should(({ request, response }) => {
expect(request.method).to.equal('POST')
expect(request.body).to.have.property('name', 'Ada Lovelace')
expect(response.statusCode).to.equal(201)
})
You can also use .then(({ request, response }) => { ... }) as in the first example. These callbacks inspect the interception yielded by the completed wait; they are not polling an evolving interception object. Keep Cypress commands in the normal serial command chain rather than nesting them inside .then() when it is unnecessary.
Rank #4
Wait for the call you expect, not an arbitrary delay
cy.wait('@alias') expresses the condition the test actually needs: a matching request and its interception. An arbitrary delay such as cy.wait(1000) only waits for time to pass; it does not prove that a request happened. Cypress describes alias waits as a way to guard for the expected matching request and reduce flakiness. Registering the route too late can miss a request already sent, so establish the intercept before the trigger.
For projects using Cypress 16’s native interception path, consult the native network interception guide for version-specific behavior. Cypress documents changes involving protocol metadata, browser-rejected responses, caching, request and response fields, and timing. A cached resource that causes no network request is not seen by an intercept. The guide recommends cy.request() for testing caching behavior itself, and notes that response handlers are not governed by responseTimeout; set a timeout on cy.wait() when you need to bound the wait. Check the documentation applicable to your installed Cypress version before relying on transport details across versions.
Recommended Free Tools
Handle repeated requests and prove the call count
An alias tracks every request that matches it. Repeated calls to cy.wait('@alias') consume matching requests in order, so they work for intentionally sequenced calls:
cy.intercept('GET', '/api/items').as('getItems')
cy.get('[data-cy=refresh]').click()
cy.wait('@getItems')
cy.get('[data-cy=refresh]').click()
cy.wait('@getItems')
To inspect the history after calls have happened, use cy.get('@alias.all'). Its indices are one-based; .all is for cy.get(), not cy.wait(). If the test must prove an exact count or inspect every request, wait until the intended activity has settled, then assert against the captured history. One successful wait only proves at least one matching request was observed; it does not prove that no additional matching call occurred. Details are in Cypress variables and aliases.
Give GraphQL operations their own aliases
GraphQL applications often send multiple operations to the same endpoint, so matching only /graphql may not identify the operation the test means to wait for. Inspect the POST body and assign a per-request alias based on the operation name, using req.alias in the intercept handler. The exact matcher depends on the client’s request format; do not assume every client serializes operations identically. Cypress shows this approach in its network requests guide.
Common failures and fixes
- The wait times out because no aliased request appears. Confirm the route is registered before the triggering action, and verify that the browser action actually sends a request matching the method and URL. A response served from cache without a network request will not be observed by the intercept.
- The alias catches the wrong call, or behavior is slower than expected. Narrow the route with the relevant HTTP method and endpoint instead of matching all methods or unrelated traffic. If the wait needs a longer bound, configure its
timeout; avoid replacing the alias condition with a guessed fixed delay. - The test passes with a stub but the live integration is broken. A stub confirms how the client constructs a request and handles the controlled response. It does not verify the real backend’s response behavior; add a suitable spy-based integration test for that question.
cy.request()does not trigger the browser intercept.cy.request()is a separate API-testing command that runs from Cypress’s Node process and bypassescy.intercept(). It tests an API directly, not whether the browser application issued the request. Seecy.request()and Cypress API testing.- An assertion on protocol or timing metadata behaves differently after an upgrade. Check the native interception documentation for the installed Cypress version and browser. Avoid asserting incidental transport metadata without confirming its documented behavior.
- The test is slower after intercepting many routes. Intercept only traffic needed by the test. Cypress warns that broad interception makes it process unrelated requests such as images, analytics, feature flags, and monitoring; see optimizing test performance.
Or skip the browser setup
If your goal is to capture a webpage rather than test an application’s network request, ScreenshotNeo is a website screenshot API and MCP server: a single GET request can return a PNG, JPEG, WebP, or PDF. For a screenshot of a URL, for example:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesQuick Recap
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 API documentation for request options. It removes 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 lets AI agents use screenshot tools. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card.
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.




