Skip to content Skip to sidebar Skip to footer

Typeerror: 'undefined' Is Not A Function (evaluating 'mockbackend.expectpost(

I am trying to unit test an angularjs controller with Karma, and jasmine. Here is my test suite: describe('Controllers', function(){ var $scope, ctrl; beforeEach(module('cu

Solution 1:

Changing line 16

from

mockBackend.expectPost('bignibou/curriculum/new');

to

mockBackend.expect('POST','bignibou/curriculum/new').respond({});

somehow fixed the issue...

edit: expectPOST would have worked too... Just a typo: notice the case I used...

Solution 2:

Likely your situation will be similar to:

var a = {};
a.b();

a.b is undefined, trying to call it will give you that error.

Line 16 here is $scope.saveCurriculum(), is $scope.saveCurriculum undefined?

Post a Comment for "Typeerror: 'undefined' Is Not A Function (evaluating 'mockbackend.expectpost("