Javascript 如何使用';规格';和';摩卡多元记者';
当我使用“spec”作为报告器与“mocha multi reporters”作为gulp服务器端测试的一部分时,我在输出测试失败原因时遇到问题 例如,当我以如下标准格式将mocha reporter设置为“spec”时:Javascript 如何使用';规格';和';摩卡多元记者';,javascript,node.js,express,gulp,mocha.js,Javascript,Node.js,Express,Gulp,Mocha.js,当我使用“spec”作为报告器与“mocha multi reporters”作为gulp服务器端测试的一部分时,我在输出测试失败原因时遇到问题 例如,当我以如下标准格式将mocha reporter设置为“spec”时: .pipe(plugins.mocha({ reporter: 'spec', timeout: 10000 })) .pipe(plugins.mocha({ reporter: 'mocha-multi-rep
.pipe(plugins.mocha({
reporter: 'spec',
timeout: 10000
}))
.pipe(plugins.mocha({
reporter: 'mocha-multi-reporters',
reporterOptions: { "reporterEnabled": "spec" },
timeout: 10000
}))
我得到以下控制台输出:
Search
1) should be able to get empty search-result list
2) should be able to get search-result list with one element
0 passing (458ms)
2 failing
1) Search GET should be able to get empty search-result list:
AssertionError: expected Array [] to have property length of 1 (got 0)
2) Search GET should be able to get search-result list with 2 elements:
AssertionError: expected Array [] to have property length of 2 (got 0)
但是,当我将“spec”设置为“摩卡multi reporters”的一部分时,如下所示:
.pipe(plugins.mocha({
reporter: 'spec',
timeout: 10000
}))
.pipe(plugins.mocha({
reporter: 'mocha-multi-reporters',
reporterOptions: { "reporterEnabled": "spec" },
timeout: 10000
}))
我的控制台输出不显示前2个故障原因,而是添加了一个额外的故障并仅记录该故障:
Search
1) should be able to get empty search-result list
2) should be able to get search-result list with one element
0 passing (528ms)
2 failing
3) "after each" hook
error: message=3 tests failed., showStack=false, showProperties=true, plugin=gulp-mocha, toString=function () { [native code] }
我试着查阅了许多在线资源,了解为什么会出现这种情况,但没有找到运气。 有人知道为什么会这样吗?我现在使用mocha multi reporter的原因是,我们也可以使用mocha allure reporter作为测试失败日志记录的一部分
作为参考,我使用以下插件版本:
- “摩卡”:“5.2.0”
- “摩卡多元记者”:“1.1.7”
- “吞咽”:“4.0.0”
- “应该”:“13.2.3”(用于断言测试)