Angular $q promise Unit testing using Mocha, Chai, Sinon
问题 I'm trying to get my simple angualr $q promise unit test to work. But I've been having problems getting it to work. Here's my angular file. app.controller('theCtrl', ['$scope', '$q', function($scope, $q) { $scope.addOne = function(num) { var q = $q.defer(); if(angular.isNumber(num)) { q.resolve(num+1); } else { q.reject('NaN'); } return q.promise; } $scope.myVal = 0; $scope.promise = $scope.addOne($scope.myVal); // $scope.promise.then(function(v) {$scope.myVal = v }, function(err) {$scope