javascript - 如何使用“spec”和“mocha-multi-reporters”将失败的测试结果输出到控制台
问题描述
当我使用 ' spec ' 作为报告器和 ' mocha-multi-reporters ' 作为 gulp 的服务器端测试的一部分时,我遇到了输出测试失败原因的问题。
例如,当我将 mocha 报告器设置为标准格式的“ spec ”时,如下所示:
.pipe(plugins.mocha({
reporter: '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 ”设置为“ mocha-multi-reporters ”的一部分时,如下所示:
.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-reporters的原因是我们也可以使用mocha-allure-reporter作为测试失败日志记录的一部分。
作为参考,我正在使用以下插件版本:
- “摩卡”:“5.2.0”
- “摩卡多记者”:“1.1.7”
- “吞咽”:“4.0.0”
- “应该”:“13.2.3” (用于断言测试)
解决方案
推荐阅读
- ruby-on-rails - 如何调试 AWS S3“拒绝访问”
- java - Maven War Plugin Exclusions(需要排除整个目录)
- javascript - 键入数组中的第一项后,键入动画光标消失
- angular - ionic v4(beta) / ionic4 - 需要的最低节点/角度版本是多少?
- laravel-5 - 如何在 Laravel 中按日期排序消息
- python-3.x - 将抓取的数据导出到 CSV
- python - 如何在 NMF Python 上执行交叉验证
- java - ScheduledExecutorService 及其调度方法。这个怎么运作?
- mongodb - 在 MongoDB 聚合 $addFields 中按条件选择数组元素
- azure - Azure DataLake (ADLS) 批量下载错误请求