Cypress how to break from a nested if loop

I want to come out of a nested if loop if a particular condition is met. Below is the snippet:-

  cy.get(A).then(()=>{
  do{
        cy.get(B).each(()=>{
            switch(C){
                 case "1":
                       if(some condition){
                          this.method1()
                          return false //THIS IS NOT BREAKING THE OUTERMOST THEN LOOP !!!!!
                       }
                       method2()
                       break
                 case "2":
                       if(some condition){
                          this.method3()
                          return false
                        }
                       method4()
                       break

            } //switch ends

        }) //each ends

    }while() //do while ends

}) //Then ends

How do I break out from the switch case 1 if method1 is executed ??

Source: Ask Javascript Questions

LEAVE A COMMENT