admin管理员组文章数量:1323714
describe('some test', function() {
for(i = 0; i < someData.length; i++) {
it("test scenario "+i, function() {
assert.deepEqual(someValue, someData[i]);
});
}
});
Having the above code is not printing mutiple pass results. It is printing the below (in green color) in the console.
0 passing (42ms)
describe('some test', function() {
for(i = 0; i < someData.length; i++) {
it("test scenario "+i, function() {
assert.deepEqual(someValue, someData[i]);
});
}
});
Having the above code is not printing mutiple pass results. It is printing the below (in green color) in the console.
0 passing (42ms)
Share
Improve this question
asked Oct 14, 2019 at 19:49
krishkrish
1962 silver badges5 bronze badges
1
- Possibly related: stackoverflow./questions/750486/… – Taplar Commented Oct 14, 2019 at 19:55
1 Answer
Reset to default 6All the details are here: https://github./mochajs/mocha/issues/3074
Mocha doesn't support such behavior. The two most famous workarounds are:
- IIFE
- forEach
I would the forEach
to be slightly more elegant, here is the possible solution by Scott Santucci (github), and modified by me for your case:
someData.forEach(function(value, i) {
it(`test scenario ${i}`, function() {
assert.deepEqual(testValue, value);
})
})
本文标签: javascriptHow can I use quotitquot in a for loop in mocha testingStack Overflow
版权声明:本文标题:javascript - How can I use "it" in a for loop in mocha testing - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742125183a2421906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论