gpt4 book ai didi

javascript - 我们可以将 before 和 after block 写入 mocha 的特定测试用例(it)吗

转载 作者:行者123 更新时间:2023-11-28 15:09:33 25 4
gpt4 key购买 nike

我可以在下面写一些东西吗?我可以像我们在描述 block 中所做的那样在特定测试用例的方法之前声明吗?

describe('demo test suite', function(){
it('demo test case one', function(){.....})
it('demo test case two', function(done){
before(function(){
//Do some operation only for this particular test case
})
//Do some operation again
})
})

最佳答案

我不太清楚你的意图,但你可以嵌套描述函数:

describe('demo test suite', function(){
it('demo test case one', function(){.....})
describe('demo test case two', function(done){
before(function(){
//Do some operation
})
it('....', function(){
//Do some operation again
})
})
})

关于javascript - 我们可以将 before 和 after block 写入 mocha 的特定测试用例(it)吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37157865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com