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 !

  1. i missing ngroute dependency in module ;
angular.module('warehousesmodule', ['smart-table', 'services', 'ngroute']) 
  1. i forget rebuild *.min.js after adding dependency.
gulp default 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -