I use cypress for testing api calls. I have functions which make api calls and return a Chainable like this Cypress.Chainable<Cypress.Response<SomeClass>>. Here, SomeClass can be a custom class or simply object type. I want to create a function which will return a custom class instead of a Chainable. Is that possible in Cypress? How to do it?
function getCar(model) : Cypress.Chainable<Cypress.Response<<Car>>{
return cy.request({
method: "POST",
url: "api url"
body: {model}
headers: the headers
});
}
I'd like to return Car instead of the above return type, as shown below. How to do this in Cypress?
function getCar(model) : Car{
//the code.
}