How does requestTimeout differ from responseTimeout?
requestTimeout is how long to wait for the app to send a request (5000 ms by default), and responseTimeout is how long to wait for the response (30000 ms). The first firing usually points at the test or UI: the click did not happen, the URL or method does not match the intercept, or the intercept comes after the action. The second points at the backend. Raising both blindly is not advisable.
Cypress · Timeouts
cy.wait('@orders') failed after 5 s. Is the backend slow, or did the request never go out?
Two similar settings answer different questions. requestTimeout is whether the request went out, responseTimeout is whether the response came back. Which timeout fired decides where to look: the test and UI or the backend.
How it works
requestTimeout (5000 ms by default) is how long cy.wait('@alias') waits for the app to send a request that matches the intercept. responseTimeout (30000 ms) is how long to wait for the response: for an intercepted request in cy.wait and for cy.request. There are also defaultCommandTimeout (4000 ms) for query commands and pageLoadTimeout (60000 ms) for page loads.
Two stages of a request
Example: what each failure means
cy.intercept('GET', '/api/orders').as('orders');
cy.get('[data-cy=load]').click();
cy.wait('@orders'); // no request in 5 s: a test or UI problem
// slow backend: raise the response timeout only here
cy.wait('@orders', { responseTimeout: 60000 });
If requestTimeout fired, usually the click did not happen, the URL or method does not match the intercept, or the intercept was registered after the action. If responseTimeout fired, the request went out but the backend did not answer: look at its latency, not the test.
Limits and alternatives
Timeouts can be overridden globally in the config, per command through its options ({ requestTimeout: ... }), or for cy.request with the timeout option. A global increase hides slowness: raise them pointwise. API speed needs separate load checks, not wider timeouts.
Diagnosis step by step
When cy.wait('@alias') fails, the sequence is this. First look at the Test Runner command log: did the click happen before the wait, and is the needed request in the list. Then compare the intercept's method and URL with the real request: GET /api/orders?page=1 does not match '/api/orders' without a pattern, you need '/api/orders*' or an object with query. Finally check the order: the intercept is registered before the action. Only when the request is in the log but there is no response are we talking about responseTimeout and the backend.
// Three levels: a command, a request wait, an API call
cy.get('[data-cy=load]', { timeout: 10000 }).click();
cy.intercept('GET', '/api/orders*').as('orders');
cy.get('[data-cy=load]').click();
cy.wait('@orders', { requestTimeout: 8000, responseTimeout: 45000 })
.its('response.statusCode')
.should('eq', 200);
cy.request({ url: '/api/report', timeout: 90000 }); // a long report
If you set only timeout, it becomes the default for both waiting timeouts, and the more specific options override it. So an increase should be pointwise and have its reason in a comment or ticket, not somewhere in the global config. For comparison: pageLoadTimeout (60 s) is about page loading, defaultCommandTimeout (4 s) about query commands and assertions.
Common mistakes
- Raising
responseTimeoutwhenrequestTimeoutfired: the request never went out, waiting longer will not help. - Setting the intercept after the click: the request has already passed.
- Raising every timeout to a minute "to stop flakiness": the test fails more slowly, not less often.
Check yourself
cy.wait('@orders') fails after 5 seconds. Which setting fired and what do you check?
Answer
requestTimeout: the request was not sent. Check that the UI action happened and that the intercept matches URL and method and sits before the action.
The request went out and the response came after 40 s. What do you do with the timeout?
Answer
responseTimeout is 30 s by default, so the test fails. But first a question for the backend: 40 seconds is a problem, not a reason to raise the limit.
requestTimeout is five seconds for the request to be sent at all; responseTimeout is thirty for the response to arrive. Middle/Senior: The first usually points to the test or UI (the click did not happen, intercept after the action), the second to the backend. So I do not raise both blindly but look at which one fired.