Jasmine2: get current spec name

前端 未结 6 699
天涯浪人
天涯浪人 2020-12-15 19:34

In Jasmine 1.3, we had this option to the get current spec and suite names:

describe(\"name for describe\", function () {
    it(\"name for it\", function ()         


        
6条回答
  •  轮回少年
    2020-12-15 20:26

    The reason this no longer works is because this is not the test. You can introduce a subtle change to your declarations however that fix it. Instead of just doing:

    it("name for it", function() {});
    

    Define the it as a variable:

    var spec = it("name for it", function() {
       console.log(spec.description); // prints "name for it"
    });
    

    This requires no plug-ins and works with standard Jasmine.

提交回复
热议问题