jeudi 3 septembre 2015

Karma - How to debug controller in Unit Testing AngularJS

Is possible debug the controller in unit testing?

Actually, I can debug the Spec.js file.

this is my controller code

angular.module('app', [])
.controller('PasswordController', function PasswordController($scope) {
    $scope.password = '';

    $scope.grade = function () {
        var size = $scope.password.length;
        if (size > 8) {
            $scope.strength = 'strong';
        } else if (size > 3) {
            $scope.strength = 'medium';
        } else {
            $scope.strength = 'weak';
        }
    };
});

But when I open the controller for example in Chrome, It displays the following code

var __cov_8V5V73zRqzgMjN4umkcw8g = (Function('return this'))();
if (!__cov_8V5V73zRqzgMjN4umkcw8g.__coverage__) {__cov_8V5V73zRqzgMjN4umkcw8g.__coverage__ = {}; }
__cov_8V5V73zRqzgMjN4umkcw8g = __cov_8V5V73zRqzgMjN4umkcw8g.__coverage__;
if (!    (__cov_8V5V73zRqzgMjN4umkcw8g['D:/workspace/staging/WL1/OTP/src/Server/WebApp/app/features/configureDatasets/DeleteThis.js'])) {
__cov_8V5V73zRqzgMjN4umkcw8g['D:/workspace/staging/WL1/OTP/src/Server/WebApp/app/features/configureDatasets/DeleteThis.js'] = {"path":"D:/workspace/staging/WL1/OTP/src/Server/WebApp/app/features/configureDatasets/DeleteThis.js","s":{"1":0,"2":0,"3":0,"4":1,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0},"b":{"1":[0,0],"2":[0,0]},"f":{"1":0,"2":0},"fnMap":{"1":{"name":"PasswordController","line":18,"loc":{"start":{"line":18,"column":34},"end":{"line":18,"column":70}}},"2":{"name":"grade","line":25,"loc":{"start":{"line":25,"column":4},"end":{"line":25,"column":21}}}},"statementMap":{"1":{"start":{"line":17,"column":0},"end":{"line":35,"column":3}},"2":{"start":{"line":22,"column":4},"end":{"line":22,"column":18}},"3":{"start":{"line":23,"column":4},"end":{"line":23,"column":21}},"4":{"start":{"line":25,"column":4},"end":{"line":34,"column":5}},"5":{"start":{"line":26,"column":8},"end":{"line":26,"column":38}},"6":{"start":{"line":27,"column":8},"end":{"line":33,"column":9}},"7":{"start":{"line":28,"column":12},"end":{"line":28,"column":35}},"8":{"start":{"line":29,"column":15},"end":{"line":33,"column":9}},"9":{"start":{"line":30,"column":12},"end":{"line":30,"column":35}},"10":{"start":{"line":32,"column":12},"end":{"line":32,"column":33}}},"branchMap":{"1":{"line":27,"type":"if","locations":[{"start":{"line":27,"column":8},"end":{"line":27,"column":8}},{"start":{"line":27,"column":8},"end":{"line":27,"column":8}}]},"2":{"line":29,"type":"if","locations":[{"start":{"line":29,"column":15},"end":{"line":29,"column":15}},{"start":{"line":29,"column":15},"end":{"line":29,"column":15}}]}}};
}
__cov_8V5V73zRqzgMjN4umkcw8g = __cov_8V5V73zRqzgMjN4umkcw8g['D:/workspace/staging/WL1/OTP/src/Server/WebApp/app/features/configureDatasets/DeleteThis.js'];
__cov_8V5V73zRqzgMjN4umkcw8g.s['1']++;angular.module('app',[]).controller('PasswordController',function PasswordController($scope)     {__cov_8V5V73zRqzgMjN4umkcw8g.f['1']++;__cov_8V5V73zRqzgMjN4umkcw8g.s['2']++;var vm=this;__cov_8V5V73zRqzgMjN4umkcw8g.s['3']++;vm.password='';function grade(){__cov_8V5V73zRqzgMjN4umkcw8g.f['2']++;__cov_8V5V73zRqzgMjN4umkcw8g.s['5']++;var size=vm.password.length;__cov_8V5V73zRqzgMjN4umkcw8g.s['6']++;if(size>8){__cov_8V5V73zRqzgMjN4umkcw8g.b['1'][0]++;__cov_8V5V73zRqzgMjN4umkcw8g.s['7']++;vm.strength='strong';}else{__cov_8V5V73zRqzgMjN4umkcw8g.b['1'][1]++;__cov_8V5V73zRqzgMjN4umkcw8g.s['8']++;if(size>3){__cov_8V5V73zRqzgMjN4umkcw8g.b['2'][0]++;__cov_8V5V73zRqzgMjN4umkcw8g.s['9']++;vm.strength='medium';}else{__cov_8V5V73zRqzgMjN4umkcw8g.b['2'][1]++;__cov_8V5V73zRqzgMjN4umkcw8g.s['10']++;vm.strength='weak';}}};});

How can I debug the controller code in Unit Testing??

Aucun commentaire:

Enregistrer un commentaire