繁体   English   中英

我们可以在块之前和之后写到摩卡咖啡的特定测试用例吗

[英]can we write before & after block to a particular test case (it) of mocha

我可以在下面写些东西吗? 我可以像在describe块中那样在对特定测试用例之前声明方法吗?

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
   })     
 })
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM