angularjs - Get angular constants in Karma -
given app startup:
angular.module("starter", [ "ionic" ]) .constant("debug", true) .run(function() { /* ... */ });
how test value of debug
?
when trying with:
describe("app", function() { beforeeach(function() { module("starter"); }); describe("constants", function() { describe("debug", inject(function(debug) { it("should boolean", function() { expect(typeof debug).tobe("boolean"); }); })); }); });
i get
typeerror: 'null' not object (evaluating 'currentspec.$modules') @ workfn (/%%%/www/lib/angular-mocks/angular-mocks.js:2230) @ /%%%/www/js/app_test.js:14 @ /%%%/www/js/app_test.js:15 @ /%%%/www/js/app_test.js:16
make sure beingness instantiated in right place. in case, beforeeach
not beingness run load module, because debug
beingness inject()
ed in describe
block, not it
block. next works properly:
describe("app", function() { var debug; beforeeach(function() { module("starter"); }); describe("constants", function() { describe("debug", function() { it("should boolean", inject(function(debug) { expect(typeof debug).tobe("boolean"); })); }); }); });
angularjs ionic-framework karma-runner karma-jasmine
No comments:
Post a Comment