本文介紹了Jasmine:如何獲取當前測試的名稱的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
有沒有辦法獲取當前正在運行的測試的名稱?
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模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!