Node.js 之前,摩卡咖啡在一个套房中的每一个都在另一个套房中运行

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

我有两个测试套件(我使用的是mocha的TDD UI,它使用
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)
    }
})