用因果报应测试AngularJS时的依赖性问题

用因果报应测试AngularJS时的依赖性问题,angularjs,testing,dependency-injection,karma-runner,Angularjs,Testing,Dependency Injection,Karma Runner,我在业力测试场景中遇到依赖问题。 准备环境时,如下所示: beforeEach(module('printecAdminApp')); beforeEach(inject(function(restService) { testRestService = restService; injector = angular.injector(['ng']); })); 测试场景如下: it('simple REST GE

我在业力测试场景中遇到依赖问题。 准备环境时,如下所示:

    beforeEach(module('printecAdminApp'));
    beforeEach(inject(function(restService) {
            testRestService = restService;
            injector = angular.injector(['ng']);
        }));
测试场景如下:

it('simple REST GET', function() {
        injector.invoke(function($http) {
            var getResult,
                        restOpt = testRestService.prepareRestCallObj(); 
                       //returns {method: 'GET', url : '...'}

            runs(function() {
                        $http(restOpt).then(.....
            });
            waitsFor(function() {
                return getResult;
            }, 'get result', 50);           
            runs(function() {
                expect(getResult).toEqual({"status" : true});
            });
        });
    });
它工作正常。但我想将
restService
依赖项从代码的环境部分转移到场景中,因为我想去掉静态
testRestService
变量。比如$http。但如果我试着用同样的方法——用$http声明

injector.invoke(function($http, restService) {  

我收到以下错误:错误:[$injector:unpr]未知提供程序:restServiceProvider您在每个模块(模块名(“您的模块名”)之前都输入了吗?是的,我输入了-我忘了在上面的代码中输入。现在看,代码被编辑了