I have 2 files:
- Test Specs
- API layer (in which all API's are written like cy.request(). I am returning API response from here
I need to use the response of API in my test spec. But when I try to use the response I am getting undefined
That is how I returning my response
testFun() {
cy.request({
method: "GET",
url: `${this.objectFactory.url}/api-v7/listings/`,
headers: {
accept: "application/json",
Authorization: this.objectFactory.authorization,
cookie: this.objectFactory.cookie,
},
}).then((response) => {
return response;
}
});
});
}
And in spec file, I am calling this function and getting undefined