Neh*_*pta 14 arrays unit-testing mocha.js angularjs chai
执行以下单元测试给出"错误:[$ injector:unpr]未知提供者:$ stateProvider < - $ state".我已将angular-ui-router.min.js附加在karma文件中.
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");
});
});
});
Run Code Online (Sandbox Code Playgroud)
JB *_*zet 30
您尚未加载任何模块,因此根本没有可用的服务.在beforeEach之前添加:
beforeEach(module('ui.router'));
Run Code Online (Sandbox Code Playgroud)