Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: [$injector:unpr] Unknown provider: $stateProvider <- $state

Executing below unit test gives "Error: [$injector:unpr] Unknown provider: $stateProvider <- $state". I have attached the angular-ui-router.min.js in karma file.

 describe("Unit tests", function() {

  var $rootScope, $injector, $state;
  console.log("hello");

  beforeEach(inject(function(_$rootScope_, _$state_, _$injector_, $templateCache) {
    console.log("hello1");
    $rootScope = _$rootScope_;
    $injector = _$injector_;
    $state = _$state_;
  }));

  describe("states", function() {
    it("verify state configuration", function() {
        var config = $state.get("DRaaS");
        console.log(config, "cc");
    });
  });
});
like image 282
Neha Gupta Avatar asked Feb 26 '15 08:02

Neha Gupta


1 Answers

You haven't loaded any module, so no service at all is available. Add this before your beforeEach:

beforeEach(module('ui.router'));
like image 69
JB Nizet Avatar answered Nov 08 '22 04:11

JB Nizet