有没有办法获取当前正在运行的测试的名称?
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
这篇关于Jasmine:如何获取当前测试的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 javascript 认为文档“准备好"之前,如何让How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 认为文档“准备好
jasmine 运行和等待实际上是做什么的?What do jasmine runs and waitsFor actually do?(jasmine 运行和等待实际上是做什么的?)
如何提供模拟文件来更改 <input type='filHow to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模拟文件来更改 lt;input type=filegt; 的事
如何使用 Jasmine 对链式方法进行单元测试How to unit test a chained method using Jasmine(如何使用 Jasmine 对链式方法进行单元测试)
如何将 $rootScope 注入 AngularJS 单元测试?How do I inject $rootScope into an AngularJS unit test?(如何将 $rootScope 注入 AngularJS 单元测试?)
Jasmine - 如何监视函数中的函数调用?Jasmine - How to spy on a function call within a function?(Jasmine - 如何监视函数中的函数调用?)