angularjs - Unknown provider in angular unit testing -



angularjs - Unknown provider in angular unit testing -

i have controller:

angular.module("controllers").controller("addcontroller", function($rootscope, $scope, $location, $timeout, $routeparams, todos, messagequeue) { // ... code });

and test:

describe("addcontroller", function() { var ctrl; var scope; beforeeach(module('controllers')); beforeeach(inject(function($rootscope, $controller) { scope = $rootscope.$new(); ctrl = $controller('addcontroller', { $scope: scope }); })); it("should available", function() { expect(ctrl).not.tobe(undefined); }); });

karma says:

error: [$injector:unpr] unknown provider: $routeparamsprovider <- $routeparams http://errors.angularjs.org/1.2.27-build.533+sha.c8c2386/$injector/unpr?p0=%24routeparamsprovider%20%3c-%20%24routeparams

but in karma.config importing bower_components/angular-route/angular-route.js. here:

module.exports = function(config) { config.set({ basepath: '', frameworks: ['jasmine'], files: [ 'bower_components/angular/angular.js', 'bower_components/angular-route/angular-route.js', 'bower_components/angular-mocks/angular-mocks.js', 'app/scripts/app.js', 'app/scripts/services/mod.js', 'app/scripts/directives/mod.js', 'app/scripts/controllers/mod.js', 'app/scripts/**/*.js', 'test/spec/**/*spec.js' ], exclude: [ ], preprocessors: { }, reporters: ['progress'], port: 9876, colors: true, loglevel: config.log_info, autowatch: true, browsers: ['firefox'], singlerun: false }); };

i bit puzzled. anyone?

you can pass '$routeparams' object $controller call, then:

beforeeach(inject(function($rootscope, $controller) { scope = $rootscope.$new(); ctrl = $controller('addcontroller', { $scope: scope, $routeparams: {id: '...'} }); }));

angularjs

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -