Jasmine:如何获取当前测试的名称
有没有办法获取当前正在运行的测试的名称?
Is there a way of getting the name of the currently running test?
一些(高度简化的)代码可能有助于解释.我想避免 "test1"/"test2"
在对 performTest
的调用中重复:
Some (heavily simplified) code may help explain. I want to avoid the duplication of "test1" / "test2"
in the calls to performTest
:
describe("some bogus tests", function () {
function performTest(uniqueName, speed) {
var result = functionUnderTest(uniqueName, speed);
expect(result).toBeTruthy();
}
it("test1", function () {
performTest("test1", "fast");
});
it("test2", function () {
performTest("test2", "slow");
});
});
<小时>
更新我看到我需要的信息在:
UPDATE I see the information I need is in:
jasmine.currentEnv_.currentSpec.description
或者可能更好:
jasmine.getEnv().currentSpec.description
推荐答案
jasmine.getEnv().currentSpec.description
相关文章