jeudi 26 mai 2016

karma can I mock service but not include it

My test is running into an error saying the following from and angular site

Unknown provider: UserServiceProvider <- UserService <- ResourceService <- taOptions

Error: [$injector:unpr] http://ift.tt/1ZsJvtS$injector/unpr?p0=UserServiceProvider%20%3C-%20User Service%20%3C-%20ResourceService%20%3C-%20taOptions

When I include the service on karma.conf it tells me there are errors on the service.js and is trying to test it. Is there a way for me to mock the service without including it?

I tried it like this but it isn't working:

inject(function(_$injector_) {
  var $controller;
  this.httpBackend = _$injector_.get('$httpBackend');
  this.rootScope = _$injector_.get('$rootScope');
  $controller = _$injector_.get('$controller');
  this.scope = this.rootScope.$new();
  $q = $injector.get('$q');

  this.UserService = {

  };
...

Aucun commentaire:

Enregistrer un commentaire