cypress-recurse
cypress-recurse copied to clipboard
Is it possible to log response from cy.request() when recursion ends?
I was wondering if it's possible to log response from cy.request() when recursion ends?
Like { error: response.body }
can you provide the full example of what you are trying to do?
I meant, is it possible to output cypress default error mesage instead of message Recursion hits the limit? By cypress default error messages I mean for example
When we use cy.request in recursion, and when recursion hits the limit, I would like to get message like "The request we sent...." "Response body is ...."
And same for dom commands,
I am not sure what you want the error message to be, can you provide a test and a screenshot of what you want the error to look like?
Instead of error max time limit is reached
I would like to have Cypress error
I mean to get somehow original error from cypress when last iteration is failed
Is the error thrown from the predicate function?
Sent from my iPhone
On Mar 23, 2022, at 15:03, Roman Khomitskyi @.***> wrote:
Instead of error max time limit is reached
I would like to have Cypress error
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
const apiRequest = (): Cypress.Chainable<Cypress.Response<any>> => {
return cy.request({ followRedirect: false, failOnStatusCode: false, ...options });
};v
const shouldBeAuthorized = (response): boolean => response.status !== 401;
return recurse(apiRequest, shouldBeAuthorized, { post: getNewToken, log: true, limit: 5, delay: 1000 }).then(
response => {
if (clientErrors.includes(response.status) || serverErrors.includes(response.status)) {
throw new Error(
`Status code ${response.status} Request Headers ${JSON.stringify(
response.requestHeaders
)} Response Body ${JSON.stringify(response.body)} `
);
}
return response;
}
);
Here is my use case Instead of my custom Error and error max time limit is reached I would like to get Cypress Error when the last iteration is failed Is it possibe?