0

I'm trying to test an Angular controller method that returns a promise. I stubbed out the promise-returning method (using a sinon stub), but when the promise is resolved (fulfilled), the registered success/onFulfilled handler does not get called. Basically, I can't get resolved promises in a Jasmine test to fire any of its registered handlers. See code here - http://cl.ly/code/1o1s2Y2F381c

Please advise. Thanks.

1
  • You need to manually run a digest. Commented Apr 28, 2014 at 5:14

1 Answer 1

0

Turns out, I had to use Jasmine's runs and waitsFor functions to basically tell jasmine to hold off moving on to the next test until I'm done with this test. Seems you need to do this if any part of your test runs in a future turn of the event loop (i.e. is async).

You could also use an extension like jasmine.async https://github.com/derickbailey/jasmine.async or jasmine-as-promised https://github.com/ThomasBurleson/jasmine-as-promised .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.