Jasmine2:获取当前的规格名称 [英] Jasmine2: get current spec name
本文介绍了Jasmine2:获取当前的规格名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Jasmine 1.3中,我们有获取当前规范和套件名称的选项:
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 () {
console.log(this.suite.getFullName()); // would print "name for describe"
console.log(this.description); // would print "name for it"
});
});
这在Jasmine 2.x中不再有效。
任何人都知道如何获取这些?
This does not longer work in Jasmine 2.x. Anyone knows how to fetch those?
谢谢。
推荐答案
我添加了一个新的jasmine报告器,然后获取规范名称,而不是在每个规范上定义N变量。希望可以提供帮助,谢谢。
I add a new jasmine reporter, then get the spec name without define N variable on each spec. Hope can help, thanks.
var reporterCurrentSpec = {
specStarted: function(result) {
this.name = result.fullName;
}
};
jasmine.getEnv().addReporter(reporterCurrentSpec);
这篇关于Jasmine2:获取当前的规格名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文