Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/478.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mocha框架(使用javascript)中,有没有一种方法可以重用来自描述块的特定测试用例(it块)_Javascript_Mocha.js_Spectron - Fatal编程技术网

在mocha框架(使用javascript)中,有没有一种方法可以重用来自描述块的特定测试用例(it块)

在mocha框架(使用javascript)中,有没有一种方法可以重用来自描述块的特定测试用例(it块),javascript,mocha.js,spectron,Javascript,Mocha.js,Spectron,我对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

我对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

您是否可以将传递给it的函数重构为它自己的函数

例如 比如说

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

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


function customReusableFunction(){
  // do stuff here
}

嗨,谢谢你的回复。我添加重构函数作为测试步骤,并完全重用整个测试用例。我不想在每个测试套件中复制粘贴相同的测试用例。我只是想通过重用测试用例本身来减少代码的重量,而不仅仅是functions.test suite1.js test suite2.js test suite3.js test suite4.js,每个套件都位于不同的文件中。我想在不同的文件中定义登录测试用例,并在所有4个测试套件中使用此测试用例(it块)。