title: Cypress conditional quit runner/test
body: <p>So I built out a command that I'm using in multiple tests that looks at the page and if a prompt is there then the page is redirected to another page to handle the prompt (in this case approving a schedule). Then it additionally looks at that new page and if the page has some text instead then it redirects to the home page (where the issue lies) OR it clicks the button to approve and redirects to the home page and continues normally through the test.</p>
  
  <pre><code>Cypress.Commands.add('approval_redirect', () =&gt; {
    cy.get('body').then(($body) =&gt; {
      if ($body.text().includes(
          'You must approve your weekly schedule before starting!'
        )) {
        cy.get('.container a')
          .first()
          .click()
        cy.get('main').then(($main) =&gt; {
          if ($main.text().includes('schedule')) {
            cy.get('button')
              .click()
            cy.pause()
          } else {
            cy.get('ul &gt; button')
              .click()
          }
        })
      }
    })
  })
  </code></pre>
  
  <p>Right now if it's going to the new page to verify the schedule and does NOT have a button to click it's returning home and then pausing. I put in the pause because it would then continue the test with massive failures.</p>
  
  <p>So for example in one test I have:</p>
  
  <pre><code>it('starts here', function (){
   cy.login()
     .wait(1000)
   cy.approval_redirect()
   cy.get('#Route')
     .click()
     .wait(1000)
  })
  </code></pre>
  
  <p>So in this if it redirects home after not clicking the button I'd like for it to completely stop the test. There's nothing to actually do. </p>
  
  <p>Is there a way to completely stop the runner? How do I put that in my test to check against the command for failure?</p>
  
  <p>I thought I could just wrap a function around the command with something like:</p>
  
  <pre><code>function findFailure(failure,success){cy.get...}
  </code></pre>
  
  <p>Then instead of cy.pause() I put</p>
  
  <pre><code>failure();
  return;
  </code></pre>
  
  <p>And under the ul > button I put</p>
  
  <pre><code>success();
  return;
  </code></pre>
  
  <p>Then in my test I did:</p>
  
  <pre><code>it('starts here', function (){
   cy.login()
     .wait(1000)
   cy.approval_redirect()
   const failure = function(){
    this.skip()
   }
   const success = function(){
    cy.get('#Route')
      .click()
      .wait(1000)
   }
  })
  </code></pre>
  
  <p>There are no errors and the test runs but it doesn't actually go through the command now. So how do I conditionally stop the cypress test?</p>