Stop guessing waits: stub HTTP responses with cy.intercept() in Cypress
Replace cy.server() and cy.route() with cy.intercept() and alias waits to reduce flaky E2E tests.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Replace cy.server() and cy.route() with cy.intercept() and alias waits to reduce flaky E2E tests.
Stub XHR/fetch at the browser boundary with cy.intercept() to make UI tests deterministic — registering, verifying, and recovering from silent pass-through.
Replace flaky waits with deterministic network control using Cypress cy.intercept(): stub responses, synchronize with aliases, and modify requests to cover error and slow-network states.
cy.intercept() makes Cypress tests deterministic by stubbing or spying on HTTP requests — but heavy stubbing can drift from the real API. Here's how to use it well.
Replace real API calls with deterministic stubs in Cypress using cy.intercept(). Follow a clear workflow to define, trigger, and verify interceptions, simulate errors, and recover from common pitfalls.
Learn how to use Cypress.io's cy.intercept to stub network requests, isolate frontend tests, and avoid flaky CI builds.