首先让我说我对node.js和mocha很新.它只是让我失望.我开始使用tdd方法,我正在尝试从beforeEach和afterEach函数中开始或刚刚完成的测试,但我没有运气.(我最感兴趣的是afterEach).至少我无法想出一个干净利落的方式.我唯一能想到的是将测试和套件保存在变量中,然后在afterEach()上进行一些匹配以查看哪个测试已经完成.
理想情况下,它说'test name'我希望有类似suite.test.name的东西
suite('my test suite', function() {
beforeEach(function () {
console.log('test name');
});
test('first test', function (done) {
var testarray = ['1', '3', '5', '7'];
testarray.forEach(function(num, index) {
console.log('num: ' + num + ' index: ' + index);
},
done());
});
afterEach(){
console.log('test name');
}
}
Run Code Online (Sandbox Code Playgroud)
And*_*rle 22
您将获得当前测试的名称 this.currentTest.title
afterEach(function(){
console.log(this.currentTest.title)
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5421 次 |
| 最近记录: |