Node.js 之前,摩卡咖啡在一个套房中的每一个都在另一个套房中运行
我有两个测试套件(我使用的是mocha的TDD UI,它使用Node.js 之前,摩卡咖啡在一个套房中的每一个都在另一个套房中运行,node.js,mocha.js,Node.js,Mocha.js,我有两个测试套件(我使用的是mocha的TDD UI,它使用suite(),test()而不是descripe()和it()): 运行mocha-g'first suite只运行第一套的测试,但运行beforeach,打印I不应在控制台上运行 如何使beforeach()仅在包含它的套件中运行 注意:我可以通过以下方法解决此问题: beforeEach(function(done){ this.timeout(5 * 1000); if ( this.currentTest.fu
suite()
,test()而不是descripe()
和it()
):
运行mocha-g'first suite
只运行第一套的测试,但运行beforeach,打印I不应在控制台上运行
如何使beforeach()
仅在包含它的套件中运行
注意:我可以通过以下方法解决此问题:
beforeEach(function(done){
this.timeout(5 * 1000);
if ( this.currentTest.fullTitle().includes('second suite') ) {
deleteTestAccount(ordering, function(err){
done(err)
})
} else {
done(null)
}
})
问题是每个之前的都不是TDD UI的一部分,而是BDD UI。TDD UI的相应功能是setup
。因此,尝试用setup
替换beforeach
,一切都应该按照您的预期进行:)。问题在于beforeach
不是TDD UI的一部分,而是BDD UI的一部分。TDD UI的相应功能是setup
。因此,尝试用setup
替换beforeach
,然后一切都会正常工作:)。谢谢!这有点特别,因为beforeach()
不像其他BDD风格的方法那样含糊不清。完整的差异:before()
变成suiteSetup()
,after()
变成suitetardown()
,beforeach()
变成setup()
,以及afterEach()
变成teardown()
。谢谢!这有点特别,因为beforeach()
不像其他BDD风格的方法那样含糊不清。这一整套差异是:before()
变为suiteSetup()
,before()
,beforeach()
变为setup()
,而afterEach()
变为teardown()
。
beforeEach(function(done){
this.timeout(5 * 1000);
if ( this.currentTest.fullTitle().includes('second suite') ) {
deleteTestAccount(ordering, function(err){
done(err)
})
} else {
done(null)
}
})