# Testing ember nested routes fails

**URL:** <https://discuss.emberjs.com/t/testing-ember-nested-routes-fails/2620>\
**Category:** Testing\
**Created:** [September 13, 2013, 11:34am UTC](https://discuss.emberjs.com/t/testing-ember-nested-routes-fails/2620 "2013-09-13T11:34:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iest](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/iest/32/4694_2.png) [@iest](https://discuss.emberjs.com/u/iest)\
**Post date:** [September 13, 2013, 11:34am UTC](https://discuss.emberjs.com/t/testing-ember-nested-routes-fails/2620/1 "2013-09-13T11:34:03Z")

</div>

I’m using karma with qUnit (after following [this tutorial](http://toranbillups.com/blog/archive/2013/07/21/Integration-testing-your-emberjs-app-with-QUnit-and-Karma/)) to test my Ember application. It’s mostly going well, however I’ve run into a problem that doesn’t make sense.

Given the 2 following tests:

```
test('can get to products', function() {
  visit('/products/')
    .then(function() {
      ok(find('*'));
    });
});

test('can get to catalogues', function() {
  visit('/products/catalogues')
    .then(function() {
      ok(find('*'));
    });
});

```

The first will run fine. The test runner gets to `/products` and finds something.

However, **the second test returns an error in the console:**

```
Error: 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 turned on transition logs, and the test runner is visiting `products.catalogues.index` before throwing the error.

Any ideas with this? Or is it simply a bug inside ember’s testing tools?

Both are valid routes defined inside the router…

(Also asked [on stack overflow](http://stackoverflow.com/questions/18784547/testing-ember-nested-routes-fails))

---

<div class="post-metadata">

**Author:** ![tarasm](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/tarasm/32/15980_2.png) [@tarasm](https://discuss.emberjs.com/u/tarasm)\
**Post date:** [September 13, 2013, 1:30pm UTC](https://discuss.emberjs.com/t/testing-ember-nested-routes-fails/2620/2 "2013-09-13T13:30:44Z")

</div>

I answered on StackOverflow [ember.js - Testing ember nested routes fails - Stack Overflow](http://stackoverflow.com/a/18787580/172894)

---

<div class="post-metadata">

**Author:** ![jamesarosen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jamesarosen/32/3535_2.png) [@jamesarosen](https://discuss.emberjs.com/u/jamesarosen)\
**Post date:** [September 15, 2013, 4:24am UTC](https://discuss.emberjs.com/t/testing-ember-nested-routes-fails/2620/3 "2013-09-15T04:24:42Z")

</div>

@tarasm your answer is to use `Ember.run(...)` in the route’s `#model` callback.

Unless the Ember router has gotten smarter recently, returning the result of `Ember.run` isn’t a general solution. Specifically, if you want `model` to return a promise to delay transition, `Ember.run` will hide that promise from the router.

Perhaps `visit` needs to be smarter about how it needs to work with the run-loop.
