简体   繁体   English

有没有办法从 mocha 框架中的描述块(使用 javascript)中重用特定测试用例(它块)

[英]Is there a way to reuse a specific test case ( it block ) from a describe block in mocha framework ( using javascript )

I m fairly new to mocha framework, I would like to know if we can reuse a test case from a particular describe block.我对 mocha 框架相当陌生,我想知道我们是否可以重用来自特定描述块的测试用例。

For example
//Test.js
describe("Reuse code here" , function(){

it("Want to reuse this test case " , function () {
    //do some test here .

})
})

//test1.js
in test1.js can I access the it block of test.js

Could you not just refactor the function being passed to the it into its own function?您不能将传递给它的 function 重构为它自己的 function 吗?

Eg For example例如 例如

//Test.js
describe("Reuse code here" , function(){

    it("Want to reuse this test case " , customReusableFunction)
    
})


function customReusableFunction(){
  // do stuff here
}

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

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