angularjs - Unit testing Module with with $routeParams fails? -
i'm using test case use $routeparams
without glicth can't make work on new test case.
module
i reduce content minimal
"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) { }]);
unit test
"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 () { }); }); });
if change module , controller 1 (e.g. productsmodule), run without error.
error message
error: [$injector:unpr] unknown provider: $routeparamsprovider <- $routeparams http://errors.angularjs.org/1.3.15/$injector/unpr?p0=%24routeparamsprovider%20%3c-%20%24routeparams @ /home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1 @ r (/home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1) @ /home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1 @ r (/home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1) @ (/home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1) @ workfn (/home/elopez/projects/tcs_economat/frontend/static_src/bower_components/angular-mocks/angular-mocks.js:2436) undefined
question
both modules in main app, see what's problem here ?
solution
i find solution reviewing code colleague, peer-review solution here !
- i missing
ngroute
dependency in module ;
angular.module('warehousesmodule', ['smart-table', 'services', 'ngroute'])
- i forget rebuild
*.min.js
after adding dependency.
gulp default