Recall & Review
beginner
What is stubbing responses in Cypress?
Stubbing responses means replacing real server replies with fake data during tests. It helps test how the app behaves without needing the real server.
Click to reveal answer
beginner
Why use stubbing responses in tests?
To make tests faster, reliable, and independent from real servers. It also helps test edge cases by controlling the response data.
Click to reveal answer
beginner
How do you stub a GET request in Cypress?
Use cy.intercept() with the URL and provide a fake response object. For example: cy.intercept('GET', '/api/data', { fixture: 'data.json' })
Click to reveal answer
intermediate
What is the difference between stubbing and spying in Cypress?
Stubbing changes the response to fake data. Spying only watches the request without changing it.
Click to reveal answer
intermediate
What should you consider when stubbing responses?
Make sure the stub matches the real API shape. Avoid stubbing too much to keep tests realistic. Clean up stubs after tests.
Click to reveal answer
What does cy.intercept() do in Cypress?
✗ Incorrect
cy.intercept() lets you watch or replace network requests during tests.
Why stub responses instead of calling the real server?
✗ Incorrect
Stubbing lets tests run without depending on the real server or internet.
Which command stubs a POST request in Cypress?
✗ Incorrect
cy.intercept() with method POST and a fake response stubs the POST request.
What is a fixture in Cypress stubbing?
✗ Incorrect
Fixtures are files that hold fake data to use in stubbing responses.
What happens if you don’t stub a failing server response?
✗ Incorrect
Without stubbing, tests depend on real server and may fail if server is down or slow.
Explain how to stub a network response in Cypress and why it is useful.
Think about replacing real server replies with your own data.
You got /4 concepts.
Describe the difference between spying and stubbing in Cypress testing.
One observes, the other replaces.
You got /3 concepts.