How do I focus on one spec in jasmine.js?

前端 未结 9 1919
借酒劲吻你
借酒劲吻你 2020-11-29 23:41

I have a bunch of failing specs from a rather large architectural change. I\'d like to work on fixing them one by one by tagging each one with \'focus\'.

Does jasmin

9条回答
  •  时光说笑
    2020-11-30 00:07

    This is the most simplified answer with a practical example .Even in fdescribe you can run few it blocks using it. f means focus.

    Also in a none fdescribe block which is just describe, you can select only specific it blocks by marking them as fit.

    Please run the below code and observe the console log, also read the comments in the code. Read this author's article it helps too . https://davidtang.io/2016/01/03/controlling-which-tests-run-in-jasmine.html

     //If you want to run few describe only add f so using focus those describe blocks and it's it block get run
    
      fdescribe("focus description i get run with all my it blocks ", function() {
        it("1 it in fdescribe get executed", function() {
            console.log("1 it in fdescribe get executed unless no fit within describe");
    
        });
        it("2 it in fdescribe get executed", function() {
            console.log("2 it in fdescribe get executed unless no fit within describe");
    
        });
        //but if you and fit in fdescribe block only the fit blocks get executed
        fit("3  only fit blocks in  fdescribe get executed", function() {
            console.log("If there is  a fit   in fdescribe only fit blocks  get executed");
    
        });
      });
    
      describe("none description i get skipped with all my it blocks ", function() {
            it("1 it in none describe get skipped", function() {
                console.log("1 it in none describe get skipped");
    
            });
            it("2 it in none describe get skipped", function() {
                console.log("2 it in none describe get skipped");
            });
    //What happen if we had fit in a none fdescribe block will it get run ?   yes  
           fit("3 fit in none describe get executed too eventhough it;s just describe ", function() {
                console.log("3 fit in none describe get executed too");
            }); 
          });
    

提交回复
热议问题