2013-10-11 18 views
0

足夠簡單的問題,有沒有辦法在Node.js上獲得Mocha中父級(it)語句的描述?獲取摩卡中父語句的描述

因此,例如:

describe("Describe test", function(){ 
    it("Describe this specific test", function(){ 
     console.log(message); // Where message is "Describe this specific test" 
    }); 
}); 

我主要需要這個自動,準確地寫入日誌文件。謝謝你的幫助。

回答

2

您可以使用下面的

describe("Describe test", function(){ 
    it("Describe this specific test", function(){ 
    console.log('Title:', this._runnable.title); 
    }); 
}); 
+0

這對我沒有工作,'無法讀取的undefined' – whitfin

+0

刮開屬性「標題」上面的評論,我有我的代碼封裝在一個setTimeout塊,杜。 – whitfin