javascript - AngularJS & Karma-Jasmin - Not all tests are executed, only the first one -
i want test code using karma-jasmin, when run tests first 1 gets fired. found out works when delete parts of code, i'll paste on bottom.
this whole jasmine code
describe("userhandler", function(){ var el, scope, controller, configservicespy, myservice, userdetails, mycontroller, $httpbackend; beforeeach(function () { module('agenda'); beforeeach(inject(function(_$httpbackend_){ $httpbackend = _$httpbackend_; })); inject(function (userhandler) { myservice = userhandler; myservice.userdetails = {}; myservice.userid = "p123"; myservice.userdetails.expire_timestamp = 999999999999; $httpbackend.expectget('http://..../123').respond(200, {"foo" : "bar", "foo2": "bar2", "address": { "street":"some street" }}) myservice.requestuserdetails(); userdetails = myservice.userdetails; }); inject(function($compile, $rootscope){ el = angular.element("<login-sidebar></login-sidebar>"); $compile(el)($rootscope.$new()); $rootscope.$digest(); scope = el.isolatescope() || el.scope() ; }); }); aftereach(function(){ $httpbackend.verifynooutstandingexpectation(); $httpbackend.verifynooutstandingrequest(); }); it("true true", function(){ $httpbackend.flush(); expect(true).tobe(true); }); it("requestuserdetails", function(){ $httpbackend.flush(); expect(object.keys(myservice.userdetails).length).tobegreaterthan(0); }); it("getuserstreet not null", function(){ $httpbackend.flush(); expect(myservice.userdetails.address.street).not.tobenull(); }); xit("getuserstreet null", function(){ $httpbackend.flush(); expect(myservice.userdetails.address.street).tobenull(); }); }); this output in console
chrome 43.0.2357 (mac os x 10.10.3): executed 1 of 4 (skipped 1) success (0.079 secs / 0.07 secs) so when delete parts http request works
it works when delete these lines of code
beforeeach(inject(function(_$httpbackend_){ $httpbackend = _$httpbackend_; })); inject(function (userhandler) { myservice = userhandler; myservice.userdetails = {}; myservice.userid = "p123"; myservice.userdetails.expire_timestamp = 999999999999; $httpbackend.expectget('http://..../123').respond(200, {"foo" : "bar", "foo2": "bar2", "address": { "street":"some street" }}) myservice.requestuserdetails(); userdetails = myservice.userdetails; }); aftereach(function(){ $httpbackend.verifynooutstandingexpectation(); $httpbackend.verifynooutstandingrequest(); }); what doing wrong ? why not executing test first 1 (it doesn't matter 1 of tests first one).
Comments
Post a Comment