3
我試圖使用createSpy()設置模擬單元測試與茉莉花。我在收到如何使用createSpy創建模擬對象()
TypeError:
undefined
is not a function (evaluatingjasmine.createSpy().andCallFake(function(msg) { return [] })
) (line 13).
CODE:
$scope.workInit = function() {
$scope.work_loading = true;
$scope.public_work_loading = true;
var projects = SomeService.getGroups();
var publicProjects = SomeService.getPublicGroupings('G');
…
...
}
TEST:
this.SomeService = {
getGroups: jasmine.createSpy().andCallFake(function(msg) { return [] }),
getPublicGroupings: jasmine.createSpy().andCallFake(function(msg) { return [] }),
}
it('should expect work_loading and public_loading to be false', function() {
this.scope.workInit();
expect($scope.work_loading).toEqual(false);
expect($scope.public_work_loading).toEqual(false);
});
'this.scope.workInit();'或'** this.scope.workgInit();'** ? –
其this.scope.workInit();對不起,這是一個錯字。我會更新,謝謝 – Jason