javascript - One Angular Controller Karma-Jasmine test works, but not another one -


finally got karma test working angular controller. if try execute same test controller, not working error message: error: [ng:areq] argument 'test2controller' not function, got undefined

the working test:

describe('testcontroller: - ', function() { beforeeach(module('myapp')); var scope, $controller, httpbackend;  beforeeach(inject(function ($rootscope, _$controller_, $httpbackend) {     scope = $rootscope.$new();     httpbackend = $httpbackend;     $controller = _$controller_; })); aftereach(function () {     httpbackend.verifynooutstandingexpectation();     httpbackend.verifynooutstandingrequest(); }); describe('version testing; -', function() {     it("tests version ", function() {          httpbackend.whenget('url').respond(200, {"meta":{"apiversion":"0.1","code":200,"errors":null}});         var $scope = {};         var controller = $controller('testcontroller', { $scope: $scope });         httpbackend.flush();         expect($scope.version.meta.apiversion).toequal('0.1');         expect($scope.version1).toequal('1');     }) }) }); 

everythings working fine here. 1 doesn't:

describe('test2controller: - ', function() { beforeeach(module('myapp')); var scope, $controller, httpbackend;  beforeeach(inject(function ($rootscope, _$controller_, $httpbackend) {     scope = $rootscope.$new();     httpbackend = $httpbackend;     $controller = _$controller_; })); aftereach(function () {     httpbackend.verifynooutstandingexpectation();     httpbackend.verifynooutstandingrequest(); }); describe('test 2 testing; -', function() {     it("tests test2 ", function() {          httpbackend.whenget('url').respond(200, {"meta":{"apiversion":"0.1","code":200,"errors":null}});         var $scope = {};         var controller = $controller('test2controller', { $scope: $scope });         httpbackend.flush();         expect($scope.testval).toequal('test value');     }) }) }); 

i registered test files in karma config, it's working first one. without test environment (i mean pure angular app) everything, every controller, working fine. doing wrong?

i'm wondering if error message telling truth: there isn't 'test2controller', @ least in situation. perhaps named else? or perhaps lives in source file haven't included in karma.conf.js? can't tell sure, i'm guessing test fine, , problem karma failing find controller.

you might want try debug button in browser instance karma launches. opens page can inspect in chrome dev tools or firebug or fave javascript debugger. keep diving in see karma has loaded, , may spot problem. hope helps.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -