Jasmine 如何关闭堆栈失败消息?
在运行测试套件时,当某个测试失败时,它也会显示如下堆栈消息Jasmine 如何关闭堆栈失败消息?,jasmine,protractor,Jasmine,Protractor,在运行测试套件时,当某个测试失败时,它也会显示如下堆栈消息 Failures: 1) Should validate labels Message: Failed: No element found using locator: By.cssSelector(".container h1") Stack: NoSuchElementError: No element found ......................... ......
Failures:
1) Should validate labels
Message:
Failed: No element found using locator: By.cssSelector(".container h1")
Stack:
NoSuchElementError: No element found .........................
.........
......
....
我们可以关闭这个堆栈输出吗?我试过了
protractor conf.js --no-stackTrace
还使用设置更新了conf.js文件
stackTrace: false,
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000,
includeStackTrace: false,
}
但是它总是显示堆栈输出,如何修复它?如果您正在使用和旧的量角器(我在“conf.js”文件中使用以下设置成功地禁用了测试套件中的堆栈跟踪:
我发现这个GitHub问题()对这个问题很有用。将“isVerbose”和“includeStackTrace”标志都设置为“false”对我来说很有效。我在量角器GitHub上找到了一个优雅的解决方案 你可以这样修改你的茉莉花
jasmineNodeOpts: {
...
print: function() {}
}
这解决了我的问题
includeStackTrace
已在中删除
所以之前的答案对我来说并不适用
jasmine spec reporter已更改,不再具有gradutor-configuration.md文件,因此建议也不再适用于我
然而,尽管缺少gravor-configuration.md文件,我还是发现jasmine spec reporter为我提供了可行的解决方案。
我发现在我的配置文件中,以这种方式使用jasmine spec reporter和量角器5.2.0:
setup = function() {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.TerminalReporter({
verbosity: 3,
color: true,
showStack: false }));
}
exports.config = {
onPrepare: setup
};
关键是在
TerminalReporter
中将stackTrace
参数更改为false。您在测试中是否使用了任何报告器?不确定为什么使用这些选项仍会抛出错误消息stack@FarazShuja我在答案中添加了更多的信息。我想你不能让它“沉默”直到jasmine npm
将支持isVerbose
和includeStackTrace
。我建议您在这里创建一个问题。
jasmineNodeOpts: {
...
print: function() {}
}
setup = function() {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.TerminalReporter({
verbosity: 3,
color: true,
showStack: false }));
}
exports.config = {
onPrepare: setup
};