title: How to repeat actions in cypress and get the result of each action
body: <p>I am trying to repeat a certain action in cypress defined in <code>doTheAction</code> and then get the results of those repeated actions. When I try Promise.all it immediately resolves to an array of undefined</p>
  
  <pre><code>describe("some test", () =&gt; {
    it("for each", () =&gt; {
      const data = { a: 1, b: 2 };
      Promise.all(
        Object.entries(data.en).map(([key, value]) =&gt;
          doTheAction(value).then(result =&gt; [key, result])
        )
      ).then(result =&gt; {
        debugger;
        // array of undefined before the browser did anything
        console.log(result);
      });
    });
  });
  const doTheAction = text =&gt; {
    cy.visit(
      "https://my.site"
    );
    cy.get("some input").type(text);
    return cy
      .get("the result")
      .then(result =&gt; result[0].innerText);
  };
  </code></pre>
  
  <p>When I try to chain the actions I get undefined for results when the second action is finished:</p>
  
  <pre><code>describe("some test", () =&gt; {
    it("for each", () =&gt; {
      const data = { a: 1, b: 2 };
      Object.entries(data).reduce(
        (results, [key, value]) =&gt;
          results.then(results =&gt;
            doTheAction(value).then(
              result =&gt;
                //results is undefined after the second action
                results.concat([[key, result]]) //current result
            )
          ),
        Promise.resolve([]) //initial results
      );
    }).then(results =&gt; {
      //never gets here
      console.log(results);
    });
  });
  const doTheAction = text =&gt; {
    cy.visit("https://my.site");
    cy.get("some input").type(text);
    return cy
      .get("the result")
      .then(result =&gt; result[0].innerText);
  };
  </code></pre>
  
  <p>Either with Promise.all or chaining the promises the actions will run in the correct order (cypress schedules them and runs them in order) but I don't see how it's possible to get a result out of it.</p>