angularjs - How to test promise in jasmine & karma -


i have test case follow:

it("should have valid structure", function(done){       var data;     module(app_module_name);      inject(function(_metaservice_){         metaservice = _metaservice_;                 });      metaservice.fetchentitymeta('person').then(function(data){         expect(data.status).tobe( true );         done();     });  }); 

but getting following error:

error: timeout of 2000ms exceeded. ensure done() callback being called in test. 

i have increased jasmine.default_timeout_interval not use. following code work.

    settimeout(function(){         expect(true).tobe(true);         done();     }, 5000); 

so, understanding having problem promise. question how can check data returned promise.

you not calling done() callback anywhere in test. change last statement to

metaservice.fetchentitymeta('person').then(function(data) {     expect(data.status).tobe(true);     done(); }); 

another option is

metaservice.fetchentitymeta('person').then(function(data) {     expect(data.status).tobe(true); }).then(done); 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -