我该如何模拟在AngularJS Jasmine单元测试中返回诺言的服务?
我有myService那个用途myOtherService,它可以进行远程调用,并返回promise: angular.module('app.myService', ['app.myOtherService']) .factory('myService', [ myOtherService, function(myOtherService) { function makeRemoteCall() { return myOtherService.makeRemoteCallReturningPromise(); } return { makeRemoteCall: makeRemoteCall }; } ]) 要对myService我进行单元测试,需要模拟myOtherService,以使其makeRemoteCallReturningPromise方法返回promise。这是我的方法: describe('Testing remote call returning promise', function() { var myService; var myOtherServiceMock = {}; beforeEach(module('app.myService')); // I have to inject mock when calling module(), // and module() should come …