Angular.js promise not resolving when unit testing service with karma

前端 未结 4 1319
梦如初夏
梦如初夏 2021-01-18 19:03

I am trying to unit test an Angular.js service, and need to set an expect on a promise returned from a Mock service (using Jasmine). I am using the karma unit testing framew

4条回答
  •  -上瘾入骨i
    2021-01-18 19:26

    I had this problem and resolved it by simply putting a $rootScope.$apply() at the end of my test

    Your FacebookService might be the issue, as suggested by @mpm. Are you sure it doesn't have any http calls happening inside of that Facebook dependency which wouldn't be occurring during unit testing? Are you certain that resolve has been called on the deferred yet?

提交回复
热议问题