title: How to run a cypress test multiple times one after another?
body: <p>I am creating a monopoly(a board game played with dice) using react. I have made the rolling system for the game. Now I want to test that.</p>
  
  <p>There are two buttons in my game</p>
  
  <ul>
  <li><strong>Roll Button</strong>: 
  
  <ul>
  <li>Its initially enabled</li>
  <li>When user clicks it the dices are rolled. Piece of player moves</li>
  <li>Now there are two cases
  
  <ul>
  <li>If doubles are rolled then player gets another turn to roll and this button stays enabled</li>
  <li>If doubles are not rolled this becomes disabled and other one becomes enabled.</li>
  </ul></li>
  </ul></li>
  <li><strong>End turn button:</strong> 
  
  <ul>
  <li>Initially its disabled. </li>
  <li>If die is rolled and doubles are not rolled then this one becomes enabled.</li>
  <li>When we click this turn changes and for new turn this becomes disabled and roll button becomes enabled again.</li>
  </ul></li>
  </ul>
  
  <p>Now I am using cypress to test this. I have written the test and it works for fine but just for 1 time. When I use a loop to run the test multiple time it fails</p>
  
  <pre><code>describe("Rolling System", function () {
     //The required test
     it("disables button correctly", function () {
  
        //Visits the page
        cy.visit("localhost:3000").then(() =&gt; {
  
           //A variable which tell if doubles were rolled at last roll or not 
           let isRollDisabled = false;
           for (let i = 0; i &lt; 10; i++) {
  
              //If roll is over then end the turn
              if (isRollDisabled) {
                 cy.get(".btn-end-turn").click();
              }
  
              //If roll button is enabled then click it.
              else {
                 console.log(isRollDisabled);
  
                 //Get and click button
                 cy.get(".btn-roll")
                    .click()
                    .then((x) =&gt; {
  
                       //Get the dice elements
                       cy.get(".dice").then((dices) =&gt; {
  
                          //Get the rolls of both die
                          let roll1 = dices[0].children.length;
                          let roll2 = dices[1].children.length;
  
                          //If not doubles
                          if (roll1 !== roll2) {
                             cy.get(".btn-roll").should("be.disabled");
                             console.log("roll disabled changed");
                             isRollDisabled = true;
                          } 
  
                          //If doubles are rolled
                          else {
                             cy.get(".btn-roll").should("not.be.disabled");
                             isRollDisabled = false;
                          }
                       });
                    });
              }
           }
        });
     });
  });
  </code></pre>
  
  <p>Notice the two logs in above code <code>console.log(isRollDisabled);</code> and <code>console.log("roll disabled changed");</code></p>
  
  <p>In the log I see that <code>false</code> is logged <code>10</code> times and then after that <code>"roll disabled change"</code> is logged.</p>
  
  <p>I think I have make code such that one test runs after another but I can't fix it.</p>