B · Core · intermediate · Week 3–4 · Chapter 5 of 12
cy.intercept — stub, spy, and wait
Network control separates junior from mid-level Cypress. Stub slow or flaky APIs, simulate errors, and assert request payloads — without leaving the browser.
Path progress35%
Step 1 of 4
Spy on GET
cy.intercept("GET", "/inventory.json").as("getInventory"); cy.wait("@getInventory") ensures data loaded before assert.
Do this now
Add intercept + wait to inventory test. Assert 6 items render after @getInventory.
Was this step clear?
Chapter learning outcomes
- Route matching
- Aliases @getItems
- Stub vs spy
- Fixture responses
Clear these before you leave
Side quest
Slow network simulation
Use intercept delay to test loading spinner. Assert spinner visible then hidden.