I have an angular app using AngularAMD with require.js. I want to mock a service like here:
module(function ($provide) {
$provide.service('ToolsService', function () {
var toolsServiceMock = {
someMethod: function () { }
};
return toolsServiceMock;
});
});
And inject it like:
angularAMD.inject(function ($injector) {
toolsService = $injector.get('ToolsService');
});
But $injector gives me real service instead of my mock. Also the function($provide) is never called.
When I change angularAMD.inject() to angular inject() I get the mock, but other application components don't work.
How can I tell angularAMD to use mocks instead of real implementations?
You can do the following to test the service with angularAMD.