gray-kilobyte-89541
03/23/2022, 4:32 PMfuture-gold-77198
03/23/2022, 5:22 PMpowerful-orange-86819
03/24/2022, 7:42 AMjs
let counter = 1;
let waitTime = 100;
const makeRequest= () => {
cy.request(options).then((response) => {
if (response.status !== 200 && counter < 10) {
cy.wait(waitTime);
makeRequest();
waitTime = waitTime + 100;
counter++;
} else {
expect(response.status).to.eq(200);
// some code here e.g. setting env variables
}
});
};
makeRequest(); //call the function outside
works really good for me, tested it a lot and with all kinds of query parameters and requests, also important notice is that i use this code in my custom commands, not in the testswooden-exabyte-51274
03/24/2022, 10:59 AMAssertionError: Timed out retrying after 4000ms: Expected to find content: 'Log In' but never did
powerful-orange-86819
03/24/2022, 11:48 AMwooden-exabyte-51274
03/24/2022, 12:08 PM.m-4
?wooden-exabyte-51274
03/24/2022, 12:08 PMwooden-exabyte-51274
03/24/2022, 12:09 PMpowerful-orange-86819
03/24/2022, 12:10 PMwooden-exabyte-51274
03/24/2022, 12:11 PMpowerful-orange-86819
03/24/2022, 12:12 PMwooden-exabyte-51274
03/24/2022, 12:16 PMbillions-architect-48187
03/24/2022, 2:50 PMred-flower-83890
04/04/2022, 12:43 PMacceptable-solstice-90676
04/04/2022, 10:58 PMacceptable-solstice-90676
04/04/2022, 10:58 PMbitter-fountain-36713
04/04/2022, 11:07 PMcy.on()
acceptable-solstice-90676
04/04/2022, 11:16 PMacceptable-solstice-90676
04/04/2022, 11:16 PMcy.on()
tall-animal-48628
04/06/2022, 12:16 PMvictorious-advantage-96717
04/06/2022, 5:48 PMtall-animal-48628
04/06/2022, 10:23 PMgifted-kite-7128
04/07/2022, 2:23 AMlittle-byte-59792
04/07/2022, 11:29 AMcreamy-train-56346
04/07/2022, 3:12 PMmagnificent-finland-58048
04/07/2022, 7:44 PMmagnificent-finland-58048
04/07/2022, 7:46 PMacceptable-solstice-90676
04/08/2022, 4:23 PMmagnificent-finland-58048
04/08/2022, 10:02 PMcy.reload()
?
maybe you need to cy.request() again and GET, make sure the account you need is there before using the UI
it sounds like an eventual consistency challenge, check out https://dev.to/muratkeremozcan/api-testing-event-driven-systems-7feacceptable-solstice-90676
04/09/2022, 5:58 PMcy.reload()
because I think it will delay the test, and about the cy.request()
I'll give it a try.