所以,我试图掌握测试角度,我有点卡住了......从我读过的内容(或者我从我读过的内容中理解的内容)下面应该可以工作,但是我收到以下错误:
错误:[ng:areq] 参数 'fn' 不是函数,得到对象 http://errors.angularjs.org/1.2.26/ng/areq?p0=fn&p1=not%20a%20function%2C%20got% 20对象
app = angular.module("MyApp", ["ngMock"])
myService = null
angular.module("MyApp").factory "myDependency", () ->
getSomething: ->
"awesome"
angular.module("MyApp").factory "myService", (myDependency) ->
useDependency: ->
myDependency.getSomething()
describe "myService", ->
beforeEach ->
module "MyApp", ($provide) ->
mockDependency =
getSomething: ->
"mockReturnValue"
console.log "providing"
$provide.value("myDependency", mockDependency)
inject (_myService_) ->
console.log "injecting"
myService = _myService_
it "is there", ->
expect(myService).not.toBeNull()
expect(myService.useDependency()).toEq("mockReturnValue")
同样值得一提的是,“提供者”出现在日志中,但“注入”没有