当 jasmine 上的测试失败时,我可以使用任何自动化来为特定的失败测试准备相同的环境吗?我使用karma作为规范运行程序。
例如:
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-karma
因为速度。grunt-jasmine
允许我在浏览器上运行单个测试用例,我可以使用 Chrome 开发人员工具进行调试。我为业力寻找了几个 html 记者,但他们只在输出 HTML 上说明结果。他们没有运行我可以中断和调试的规范。
最后,我写了一个 karma 插件来填补这个空白。如果有人需要:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句