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屋!
查看全文