Angular unit testing with Jasmine: how to remove or modify spyOn

Solution 1:

You can just overwrite it

updateService.getUpdate = jasmine.createSpy().and.returnValue(etc)

Solution 2:

You can override the return value of the spy

    var deferred = $q.defer();
    deferred.resolve( data1 );

    var getUpdateSpy = spyOn(updateService, 'getUpdate').and.returnValue(deferred.promise);



    var newDeferred = $q.defer();
    newDeferred.resolve( data2 );

    getUpdateSpy.and.returnValue(newDeferred.promise);