strong-eye-30896
12/26/2022, 5:53 PMstrong-eye-30896
12/26/2022, 5:53 PMkind-angle-5131
12/26/2022, 7:11 PMstrong-eye-30896
12/26/2022, 7:18 PMkind-angle-5131
12/26/2022, 7:20 PMstrong-eye-30896
12/26/2022, 8:32 PMflaky-intern-13440
12/27/2022, 3:56 AMastonishing-coat-3685
12/27/2022, 10:29 AMastonishing-coat-3685
12/27/2022, 10:29 AMastonishing-coat-3685
12/27/2022, 10:29 AMable-traffic-38184
12/27/2022, 11:32 AMbulky-night-80023
12/27/2022, 12:49 PMwonderful-match-15836
12/27/2022, 1:51 PMcold-author-79999
12/27/2022, 3:05 PMsome-oil-10020
12/27/2022, 3:10 PMwonderful-match-15836
12/27/2022, 4:57 PMwonderful-match-15836
12/27/2022, 5:06 PMkind-van-46599
12/27/2022, 7:37 PMgray-kilobyte-89541
12/27/2022, 7:38 PMkind-van-46599
12/27/2022, 7:39 PMgray-kilobyte-89541
12/27/2022, 10:32 PM.should(...)
You probably want to print it first before making assertions? Or just let the assertion print the valuebitter-fountain-36713
12/28/2022, 12:46 AMkind-van-46599
12/28/2022, 5:43 AMkind-van-46599
12/28/2022, 6:04 AMTimed out retrying after 4000ms: Expected to find element: [data-testid="SelectableCell"], but never found it. Queried from element: <span.eLrQSlFO6NNdr2YDzyOJ>
and currently I'm able to achieve the desired result using get(). I second your suggestion, but find() isn't behaving the expected way.swift-manchester-9192
12/28/2022, 10:21 AMproud-breakfast-29892
12/28/2022, 10:45 AMts
let x = {}
cy.wrap(myObject).each((object: any) => {
cy.request({
method: 'GET',
url: object.url,
qs: {
token: this.TOKEN
}
}).then((response) => {
x = {response.body.myValue}; // Here we update the X object
cy.log(x) // X is updated as expected
});
cy.log("Updated x", x); // But here, X is still empty object!
});
cy.log("Updated x", x); // Still empty object!
As you can see, I am trying to iterate over a few objects using cy.each, and for each of the object, I perform an HTTP call with the URL that is included in the object. After that, I get the response promise, and inside that promise, I update the value of X. After that, outside of the promise, I log the updated value of X. However, it still retains the old value, and is an empty object. And of course ,it is also the case after the each iteration ends, as you can see in the final line.
Why is X updated inside the response promise just fine, but stays empty outside of it?
I want to be able to have an updated X OUTSIDE of the each iterationbitter-fountain-36713
12/28/2022, 2:16 PMnutritious-analyst-96582
12/28/2022, 2:16 PMgray-kilobyte-89541
12/28/2022, 3:08 PMswift-spoon-76449
12/28/2022, 3:19 PM