自分で作成したサービスに依存するコントローラーをテストしようとしています。このサービスはDOMと通信するため、このサービスをモックしたいと思います。
これが私の現在のテストです:
describe('Player Controllers', function () {
    beforeEach(function () {
        this.addMatchers({
            toEqualData: function (expected) {
                return angular.equals(this.actual, expected);
            }
        });
    });
    describe('TestPSPlayerModule', function () {
        var $httpBackend, scope, ctrl;
        beforeEach(module('PSPlayerModule'));
        beforeEach(inject(function (_$httpBackend_, $rootScope, $controller) {
            $httpBackend = _$httpBackend_;
            scope = $rootScope.$new();
            ctrl = $controller(PlayerController, { $scope: scope });
        }));
        it('should request a clip url from the server when clipClicked is called', function () {
            expect(1).toBe(1);
        });
    });
});
私のコントローラーは次のようになります。
w.PlayerController = function ($scope, $http, $window, speedSlider, $location) {
    ...
}
だから私がモックしたいのはspeedSliderです。
テストコードで作成した、スピードスライダーの偽の実装を提供できるモジュールを使用することを考えたので、test.jsファイルの先頭に次を追加しました。
module('TestPSPlayerModule', []).factory('speedSlider', function () {
    return = {
       ...
    };
});
次に、そのモジュールを具体的なモジュールの代わりにbeforeEach()呼び出しにリストしますが、そうすると、次のエラーが発生します。
Injector already created, can not register a module!
したがって、自分のサービスの1つの模擬実装を提供するためのより良い方法があるはずだと思います。おそらくsinon.jsを使用できるもの...