2013-10-11 20 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