I'm using the functionality described in the Ember.js Asynchronous Routing guide. Namely, I'm returning a promise from my asynchronous route's model
hook to delay transitioning to the route, which works as expected.
However, it breaks the ability to unit test my app. When I run my tests, I get the following error in the console:
Assertion failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in an Ember.run
I've wrapped all code with asynchronous side-effects in Ember.run
, but I still get the error.
Here's a JSFiddle with a minimal example: http://jsfiddle.net/nRHfv/3/
The example is based on the Ember Starter Kit and the test runner it comes with. It has a working asynchronous index route. If you set testing: false
to true
in the _config
object (line 10), it will turn on the test suite, and you should see the above error in your console.
My asynchronous route's model
hook is on line 38. I've tried several variations on wrapping the code in Ember.run
. For example, I've tried defining the promise outside of Ember.run
, doing all the asynchronous stuff inside, and then returning the promise outside. I've also tried wrapping just the contents of then()
in Ember.run
, like I've seen on some other answers (e.g. ember integration test error. dealing with asynchronous side-effects).
What am I doing wrong?