我的模块和测试声明如下所示,但是当我尝试将ContentBlocksService注入beforeEach时(mock.inject((ContentBlocksService)...它表示未知提供者ContentBlocksServiceProvider ...任何想法?
模块:
module projName.ContentBlocks {
"use strict";
console.log("contentBlocks.module: start");
angular.module("projName.contentBlocks", [
"ui.router",
"ui.bootstrap",
"ui.bootstrap.tpls",
"textAngular",
"as.sortable",
// shared modules
"projName.filters"
])
.service("ContentBlocksService", ContentBlocksService)
// etc
}
试验:
module projName.ContentBlocks {
"use strict";
describe("ContentBlocksDetailPageService", () => {
beforeEach(mock.inject((_$http_, _$log_, _$q_, _$httpBackend_, _$rootScope_) => {
log = _$log_;
httpMock = _$httpBackend_;
alertService = new Shared.AlertService(_$q_, _$log_);
$q = _$q_;
$http = _$http_;
$rootScope = _$rootScope_;
}));
/// etc
答案 0 :(得分:1)
beforeEach(mock.module('projName.contentBlocks'));
在beforeEach(mock.inject(...))
之前需要才能在规范中加载模块。