在Jasmine 3中我应该使用什么而不是合适和fdescribe?

时间:2018-05-28 07:23:11

标签: angular testing jasmine karma-runner

我收到错误:

ERROR: 'DEPRECATION: fit and fdescribe will cause your suite to report an 'incomplete' status in Jasmine 3.0'

我为Jasmine 3.0做了一个RTFM,但它没有提到有关弃用的任何内容:https://jasmine.github.io/api/3.0/global.html#fit

2 个答案:

答案 0 :(得分:4)

根据您与fit docs的链接

fit将重点关注一个或一组测试。

因此,如果您有5个测试,分别为3 it和2 fit,那么Jasmine将只运行2个适合的测试。

ERROR: 'DEPRECATION: fit and fdescribe will cause your suite to report an 'incomplete' status in Jasmine 3.0'

ERROR --> WARNING:告诉您只会运行fit'S,因此不完整测试。

谢谢。

答案 1 :(得分:0)

他们已经修复了我正在使用茉莉v3.3.1的警告,但我没有看到这样的消息。

enter image description here

所以我们仍然可以使用fit和fdescribe,请阅读下面的代码及其注释。经过测试且易于理解。

//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");
        }); 
      });