断言错误 - 输出有噪音.如何仅显示断言
AssertionError - output is noisy. How do I show only Assertion
从入门运行实习单元测试示例时,当我更改 Hello 单元脚本并运行它以使其断言时,它似乎显示比我需要的更多细节(嘈杂)。 此输出是否正确? 有没有办法只显示断言错误行,也许显示发生此断言的文件/行?
unit_hello.js:
define([
'intern!object',
'intern/chai!assert',
'app/hello'
], function (registerSuite, assert, hello) {
registerSuite({
name: 'hello',
greet: function () {
assert.strictEqual(hello.greet('Name'), 'Hello, Name!',
'hello.greet should return a greeting for the person name in the first argument');
assert.strictEqual(hello.greet(), 'Hello, World!',
'hello.greet with no arguments should return a greeting to "world"');
}
});
});
输出:
user@pcname:~/intern_example$ ./node_modules/.bin/intern-client config=tests/intern_unit
FAIL: main - hello - greet (1ms)
AssertionError: hello.greet with no arguments should return a greeting to "world": expected 'Hello, world!' to equal 'Hello, World!'
at Function.assert.strictEqual <node_modules/intern/node_modules/chai/chai.js:2487:32>
at Test.registerSuite.greet [as test] <tests/unit/unit_hello.js:13:20>
at Test.run <node_modules/intern/lib/Test.js:169:19>
at <node_modules/intern/lib/Suite.js:237:13>
at signalListener <node_modules/intern/node_modules/dojo/Deferred.js:37:21>
at Promise.then.promise.then <node_modules/intern/node_modules/dojo/Deferred.js:258:5>
at runTest <node_modules/intern/lib/Suite.js:236:46>
at <node_modules/intern/lib/Suite.js:249:7>
at process._tickCallback <node.js:419:13>
1/1 tests failed
1/1 tests failed
您可以编写和加载自己的自定义报告器,以输出您想要或不想要的任何信息。标准报告器将始终提供完整的堆栈跟踪。
有一个 filterErrorStack 配置选项,它告诉 Intern 通过删除非应用程序代码来清理错误堆栈跟踪。
它从版本 3.4(发布于 18.11.2016)开始。
相关文章:
- PHP中的setcookie仅适用于localhost
- ReactJS映射:如何仅在url变量不为空时呈现html链接
- .Find()仅显示可见元素
- 仅加载事件序列
- 如何使bxslider仅在移动视图中处于活动状态
- 仅在IE中,javascript中的时区名称不正确
- 清除以前的$_GET值或不获取仅隐藏字段的值
- 有没有一种方法可以仅使用HTML/CSS来隐藏基于特定值的数据单元格
- 单击仅在第二次单击后有效
- ng消息仅在触摸时显示错误,并在错误的初始显示上转换
- 仅重新加载网页的一部分
- 仅使用文件对象选择单个文件
- 加载器组件仅加载一次
- 对于loop.if-仅在经过所有间隔后返回true
- 全局标志仅与第一个匹配项匹配的Regexp
- 仅为一个窗体运行应用程序脚本
- 是否可以仅通过jQuery将图像替换为用户动态选择的另一个图像
- 边栏仅在单击外部时关闭单击
- 如何仅在首次登录时显示弹出窗口
- 断言错误 - 输出有噪音.如何仅显示断言