API testing
# best-practices
k
For API testing I'm wanting to return the response body for the call. Is this a reccomend way to do this or is there a better way?
e
Hi, i'd make the function return the
cy.request
directly so you can chain
.then()
to get the response where you call the function
k
so your saying something like this? function searchCustomPrograms({accessToken}) { return cy .request({ method: 'GET', url:
${defaultEndPoint}/custom-program/search?
, headers: { Authorization:
Bearer ${accessToken}
, }, }) .then(function (res) { expect(res.status).to.eq(200); }); }
2 Views