# Testing route transitions

**URL:** <https://discuss.emberjs.com/t/testing-route-transitions/4481>\
**Category:** Testing\
**Created:** [March 13, 2014, 5:03pm UTC](https://discuss.emberjs.com/t/testing-route-transitions/4481 "2014-03-13T17:03:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/pete/32/15575_2.png) [@pete](https://discuss.emberjs.com/u/pete)\
**Post date:** [March 13, 2014, 5:03pm UTC](https://discuss.emberjs.com/t/testing-route-transitions/4481/1 "2014-03-13T17:03:30Z")

</div>

So I have a simple controller that calls transitionTo after a promise has resolved. I am looking for a way to integration test this transition.

I have mocked out the library that returns the promise so it returns a promise which then resolves. I would like to test and see that when the promise is resolved the call to transitionTo is made, and the route is changed, but I can’t figure out a way to do it.

Code below (coffeescript)…

The test:

```
module 'signup succeeds', {
  setup: ->
    Library.User.signup = ->
      return new Ember.RSVP.Promise( (resolve) ->
        console.log 'resolving'
        resolve({})
      )
}

test 'the route changes', ->
  visit '/sign-up'
  andThen ->
    fillIn '.email', 'badger@me.com'
    fillIn '.password', 'giraffe'
    click 'button.login-btn'
    andThen ->
      // test the route after the promise resolves here

```

The controller:

```
App.SignUpController = Ember.Controller.extend

  email: ''
  password: ''

  actions:
    signUp: ->

      credentials =
        username: @get 'email'
        password: @get 'password'
        email: @get 'email'

      Library.User.signup credentials
        .then @callback, @errback

    callback: ->
      @transitionToRoute 'index'

    errback: (err) ->
      # TODO error reporting
      console.log err

```

Any help is greatly appreciated

---

<div class="post-metadata">

**Author:** ![limptwiglet](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/limptwiglet/32/14978_2.png) [@limptwiglet](https://discuss.emberjs.com/u/limptwiglet)\
**Post date:** [March 13, 2014, 6:25pm UTC](https://discuss.emberjs.com/t/testing-route-transitions/4481/2 "2014-03-13T18:25:06Z")

</div>

There is a property on the application controller called currentRouteName. In my tests I get the application controller via the application container:

```
App. __container__.lookup('controller:application').get('currentRouteName');

```

This will return you the path to the current route.

---

<div class="post-metadata">

**Author:** ![pixelhandler](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/pixelhandler/32/18649_2.png) [@pixelhandler](https://discuss.emberjs.com/u/pixelhandler)\
**Post date:** [March 14, 2014, 6:44pm UTC](https://discuss.emberjs.com/t/testing-route-transitions/4481/3 "2014-03-14T18:44:22Z")

</div>

I shared the integration tests for my blog app, here is a post on the topic: [Pixelhandler's blog](http://pixelhandler.com/posts/end-to-end-javascript-testing-integration-tests-using-emberjs-test-helpers)

Basically I use the Ember Test helpers as well as a few custom helpers:

- [Pixelhandler's blog](http://pixelhandler.com/posts/end-to-end-javascript-testing-integration-tests-using-emberjs-test-helpers)
- [https://github.com/pixelhandler/blog/blob/master/client/tests/support/test-helpers.js#L23-L25](https://github.com/pixelhandler/blog/blob/master/client/tests/support/test-helpers.js#L23-L25)

Integration tests that use the path() helper

- [https://github.com/pixelhandler/blog/blob/master/client/tests/integration/admin\_test.js#L19-L21](https://github.com/pixelhandler/blog/blob/master/client/tests/integration/admin_test.js#L19-L21)
- [https://github.com/pixelhandler/blog/blob/master/client/tests/integration/admin\_test.js#L68-L72](https://github.com/pixelhandler/blog/blob/master/client/tests/integration/admin_test.js#L68-L72)

---

<div class="post-metadata">

**Author:** ![shturm](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/shturm/32/9614_2.png) [@shturm](https://discuss.emberjs.com/u/shturm)\
**Post date:** [November 8, 2014, 3:19pm UTC](https://discuss.emberjs.com/t/testing-route-transitions/4481/4 "2014-11-08T15:19:04Z")

</div>

Old thread with up-to-date topic, so… You can use the following synchronous test helpers:

- `currentRouteName()`
- `currentPath()`
- `currentURL()`

Taken from Ember docs: [http://emberjs.com/guides/testing/test-helpers/#toc\_synchronous-helpers](http://emberjs.com/guides/testing/test-helpers/#toc_synchronous-helpers)
