1
我的角度控制器看起來是這樣的:如何在量角器中記錄httprequest的結果?
myApp.controller('Ctrl1', ['$scope','$http', function ($scope,$http) {
console.log('hello');
$scope.testing = 'hello man';
$http.get("https://api.github.com/repos/vmg/redcarpet/issues").success(function (data) {
// success
console.log('success');
}).error(function (error) {
// error
console.log(JSON.stringify("Failed to get t&c: " + error));
});
}]);
我的端對端測試是這樣的:
afterEach(function() {
browser.manage().logs().get('browser').then(
function (browserLog) {
console.log('\n log: ' + require('util').inspect(browserLog));
});
});
it('should show success in console', function() {
browser.get('http://localhost:63342/basic_protractor_osx/index.html');
});
當我運行量角器日誌數組是空的,而當我打開德的index.html與控制器在控制檯中顯示'成功'。我如何用量角器測試控制器,以便測試成功?
仍然不會從http調用中返回console.log? –
@bierhier你的'require'('util').inspect(browserLog)'做了什麼?只要打印它'console.log(browserLog);' – vrachlin