title: Ember CLI Controller Test: Uncaught TypeError: Cannot read property 'transitionToRoute' of null
body: <p>I have a controller I'm testing with Ember CLI, but the controller's promise will not resolve, as the controller's <code>transitionToRoute</code> method is returning <code>null</code>:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'transitionToRoute' of null</p>
  </blockquote>
  
  <p><strong>login.coffee</strong></p>
  
  <pre><code>success: (response) -&gt;
      # ...
  
      attemptedTransition = @get("attemptedTransition")
      if attemptedTransition
          attemptedTransition.retry()
          @set "attemptedTransition", null
      else
          @transitionToRoute "dashboard"
  </code></pre>
  
  <p><strong>login-test.coffee</strong></p>
  
  <pre><code>`import {test, moduleFor} from "ember-qunit"`
  
  moduleFor "controller:login", "LoginController", {
  }
  
  # Replace this with your real tests.
  test "it exists", -&gt;
      controller = @subject()
      ok controller
  
  ###
      Test whether the authentication token is passed back in JSON response, with `token`
  ###
  test "obtains authentication token", -&gt;
      expect 2
      workingLogin = {
          username: "user@pass.com",
          password: "pass"
      }
      controller = @subject()
      Ember.run(-&gt;
          controller.setProperties({
              username: "user@pass.com",
              password: "pass"
          })
          controller.login().then(-&gt;
              token = controller.get("token")
              ok(controller.get("token") isnt null)
              equal(controller.get("token").length, 64)
          )
      )
  </code></pre>
  
  <p>When the line <code>@transitionToRoute("dashboard")</code> is removed, the test passes; otherwise, the test fails.</p>
  
  <p>How can I fix this error, while still maintaining my controller logic?</p>