Jasmine测试自动化失败了

时间:2017-10-30 12:53:29

标签: debugging testing jasmine karma-runner

当jasmine上的测试失败为特定的失败测试准备相同的环境时,我可以使用任何自动化吗?我使用业力作为规范运行者。

例如:

describe("this plugin", function(){
    beforeEach(function(){
        $("body").append("<input type='text' id='myplugintester'>");
        this.plugin = $("#myplugintester").plugin({
             cond1: true,
             cond2: new Date(),
             condetc: null
        });
    }
    afterEach(function(){
         $("#myplugintester").data("plugin").destroy();
         $("#myplugintester").remove();
    }
    it("should show the correct value", function(){
         expect(this.plugin.value).toEqual("somevalue");
    });
    it("should display 'disabled' when cond3 is not null", function(){
         this.plugin.cond3 = "blabla";
         expect(this.plugin.value).toEqual("somevalue");
    });
 });

当第二种情况失败时,我必须将其写入测试页面以调试代码出错的地方。

var expect = function(){
    // filler code
};

$("body").append("<input type='text' id='myplugintester'>");
this.plugin = $("#myplugintester").plugin({
     cond1: true,
     cond2: new Date(),
     condetc: null
});
this.plugin.cond3 = "blabla";
console.log(this.plugin.value);
$("#myplugintester").data("plugin").destroy();
$("#myplugintester").remove();

是否有任何节点包自动执行此操作?或者其他开发者在这种情况下如何反应?

注意:由于速度原因,我从grunt-jasmine切换到grunt-karmagrunt-jasmine允许我在浏览器上运行单个测试用例,我可以使用Chrome开发者工具进行调试。我为业力寻找了几个html记者,但他们只在输出HTML上说明结果。它们没有运行我可以中断和调试的规范。

1 个答案:

答案 0 :(得分:0)

最后,我写了一个karma插件来填补这个空白。如果有人需要:

https://www.npmjs.com/package/karma-code-reporter

相关问题