我想在测试期间检查特定的控制台日志
it('should return logs', function(done) {
browser
.log('browser').then(function(logs){
console.log(logs);
})
...
});
我得到的是:
[ { level: 'INFO',
message: 'https://localhost:3000/ 42:14 "foo"',
timestamp: 1485785320222 },
{ level: 'INFO',
message: 'https://localhost:3000/ 43:14 "bar"',
timestamp: 1485785320222 },
{ level: 'INFO',
message: 'https://localhost:3000/ 46:14 Array[6]',
timestamp: 1485785320225 },
{ level: 'SEVERE',
message: 'https://localhost:3000/favicon.ico - Failed to load resource: the server responded with a status of 404 (Not Found)',
timestamp: 1485785320298 } ]
所以它应该只返回一个日志条目列表,比如“foo”和“bar”,这样我就可以检查它是否等于我的假设值。
我现在不确定是否需要一个“for..in”来构建我可以重用的方法,或者只是循环多个对象并查找logs.value。消息并用“”修剪零件。