Reputation: 11
We are currently trying to make test scripts for a webapp running in local. However, some requests that are working on a basic browsers get an empty response on cypress test browser, which makes the tests fail.
I heard about a rule of Node that will return an empty response for any header that is more than 80kb, however, requests in my app never exceed 80kb, so I'm wondering what is going on.
Does anyone have a clue?
{
id: -1
project_id: 3605
parent_id: 0
title: Folder
original_filename: Folder
type: FOLDER
created_datetime: 201905061228
updated_datetime: 201905061228
delete_flag: 0
folder_type: 1
}
{
"created_time":"2019-05-06 10:39:38",
"updated_time":"2019-05-06 10:39:38",
"purchase_datetime":null,
"folder_type":"1",
"id":9522,
"project_id":"3605",
"parent_id":"0",
"title":"Folder 2",
"original_filename":null,
"type":"FOLDER",
"original_xml":null,
"updated_xml":null,
"deleted_datetime":null,
"delete_flag":"0",
"status":null,
"progress":null,
"version_no":null,
"purchase_flag":null
}
This request has no response data available
Upvotes: 0
Views: 3365
Reputation: 1
I was able to solve it in my case.
I got null in ->
cy.wait(alias, options).then((xhr) => {
const status = xhr.response.body.ok; // response was null
expect(status).to.equal(true);
});
The reason for error in my case- url contains another url.
I've intercepted the url "describe-something" and then I intercepted the url "describe-something-something" which tried to intercept the first one and therefore its response was null.
The solution-
I just changed the url of the first request, instead of "describe-something" I used -> new RegExp(/\/describe-something$/)
Upvotes: 0
Reputation: 11
I had the same problem. Turns out I was unintentionally stubbing the response.
My code was:
cy.intercept('POST', '/route', {statusCode: 200}).as('someRoute'); <------WRONG
When it should be something like:
cy.intercept('/route').as('someRoute');
// code for clicking button/triggering the request
cy.wait('@someRoute').its('response.statusCode').should('eq', 200)
Upvotes: 1
Reputation: 1
I had the same problem. Try editting the cypress.json file. Put the following line "responseTimeout":{the time you want to wait} By default this time is 30000 milliseconds. This worked for me.
Upvotes: 0