我已经在使用测试用例,我使用$routeParams
而没有使用glicth,但是我无法在新的测试用例中使用它。
我将其内容减少到最小
"use strict";
angular.module('warehousesModule', ['smart-table', 'services', 'ngRoute'])
.controller('WarehouseEditCtrl', [
'$scope', '$routeParams', '$location', '$window', 'API', 'gettextCatalog', 'form',
function ($scope, $routeParams, $location, $window, API, gettextCatalog, form) {
}]);
"use strict";
describe('testModule', function () {
beforeEach(module('warehousesModule'));
describe('WarehouseEditCtrl', function () {
var $scope, ctrl, $httpBackend;
beforeEach(inject(function ($rootScope, $routeParams, $controller) {
$routeParams.compoundId = 3;
$scope = $rootScope.$new();
ctrl = $controller('WarehouseEditCtrl', {
$scope: $scope
});
}));
it('dummy', function () {
});
});
});
如果我将模块和控制器更改为另一个(例如 productsModule ),它将无误运行。
Error: [$injector:unpr] Unknown provider: $routeParamsProvider <- $routeParams
http://errors.angularjs.org/1.3.15/$injector/unpr?p0=%24routeParamsProvider%20%3C-%20%24routeParams
at /home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1
at r (/home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1)
at /home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1
at r (/home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1)
at i (/home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1)
at workFn (/home/elopez/projects/tcs_economat/frontend/static_src/bower_components/angular-mocks/angular-mocks.js:2436)
undefined
这两个模块都在我的主应用程序中,你看到这里有什么问题吗?
答案 0 :(得分:1)
我通过与同事一起审核我的代码来找到解决方案,因此同行评审就是解决方案!
ngRoute
依赖项; angular.module('warehousesModule', ['smart-table', 'services', 'ngRoute'])
*.min.js
。gulp default