Search code examples
ember.jsqunitkarma-runnerember-testing

transitionToRoute causes ember test to hang


Using ember.js v 1.5.1.

I use karma and qunit to test my ember application. In several of my tests I have situations where 1.a user clicks->2.an async call is made to our server->and then 3. a transition via "this.transitionToRoute('someroute')" in the controller is called. When it hits the transitionToRoute method while testing, karma hangs. Tried wrapping it with an ember.run call but didn't seem to help.

When I comment out the transition call it runs, and fails accordingly.

Example Test Code where it hangs and doesn't reach equal calls

test('successful registration request', function() {
  setupMockRegistrationRequests();

  visit("/register") 
  .fillIn('#email', 'test2')
  .fillIn('#password','password')
  .click('#submit')  
  .andThen(function() {
    equal(find(".register-page .form-alert").length, 0, "Should be no error");
    equal(find(".login-page").length, 1, "Should be on login screen");
  }); 
});

Controller Code

Test case runs

//this.transitionToRoute('login');

Test case hangs

   this.transitionToRoute('login');

Any body know why it is hanging?/What I can do to allow it continue?


Solution

  • The problem was that it was transitioning, but there were more async requests being made by the next route that were not being handled by my mockjax requests. This caused the testing environment to hang without any errors being thrown.