【发布时间】:2015-03-04 00:59:13
【问题描述】:
首先,这是我第一次尝试在我的应用程序中运行测试。 下面的代码是为了测试一个控制器函数的结果($scope.getActiveClients(),这个函数发出一个 $http 获取请求)返回的对象: $scope.activeClients 在我的测试运行时是未定义的。 到目前为止,我已经尝试了 jasmine 的 2.0 文档中所述的 runs() 和 waitsFor() 以及 done() 函数,但均无济于事,并收到此错误消息:
TypeError: undefined is not a function
describe 'myController', ->
beforeEach module('myApp')
$controller = undefined
beforeEach inject((_$controller_) ->
$controller = _$controller_
return
)
describe '$scope.activeClients', ->
it 'gets all active clients', ->
$scope = {}
controller = $controller('myController', $scope: $scope)
$scope.getActiveClients()
expect($scope.activeClients).toEqual xxx
return
return
return
任何指针将不胜感激
【问题讨论】:
标签: angularjs coffeescript jasmine