未知提供程序错误:使用Jasmine进行角度单元测试

时间:2016-12-02 07:16:12

标签: angularjs karma-jasmine

我正在尝试用业力测试控制器和服务。控制器单元测试工作正常,但它在测试工厂时给我错误

angular.module('dr.search.services')
.service('registerDoctor', function($uibModal, $rootScope, $timeout, dbService, $q) {
    var registerDoctor= {};

    // functions code

    return registerDoctor;
}

现在我正在尝试测试是否定义了此服务

describe('Doctor Sign up factory', function() {
  var DocSignUpFactory;

  beforeEach(module('dr.search.services'));
  beforeEach(inject(function(_registerDoctor_) {
    DocSignUpFactory = _registerDoctor_;
  }));

  it('DoctorSignUpFactory should be defined.', inject(function (DocSignUpFactory) {
      expect(DocSignUpFactory).toBeDefined();
  }));
});

我已经在karma.conf.js中添加了这些文件,就像这样

'app/components/signUpDoctor/signUpDoctor.js',
'app/components/signUpDoctor/signUpDoctor.spec.js',
'app/factories/signUpDoctor/signUpDoctor.js',
'app/factories/signUpDoctor/signUpDoctor.spec.js',

当我运行业力时,它在工厂单元测试中显示错误

Error:  [$injector:unpr] Unknown provider:  DocSignUpFactoryProvider <- DocSignUpFactory

0 个答案:

没有答案