I am using cy.request() method to send API requests and read the response in my cypress tests. But sometimes the tests fail with the following error:
CypressError: cy.request() timed out waiting 30000ms for a response from your server.
I have increased the timeout value by passing in timeout: 50000 option in the request body, but still, it is failing sometimes especially when the response is huge. Is there any other way to avoid the request timeout error?
Below is my code:
cy.request({
method: "POST",
url:"http://localhost:3001/codes/search?searchText=" +searchText.replace(" ", "%20") +"&page[size]=100",
body: {
data: {
type: "ern:code-search-request",
attributes: {
CodeCategory: filterOption
}
}
},
timeout: 50000
}).then((response: any) => {return response;})
You can use responsetimeout in cypress.json file. Cypress Docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With