question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QUnit integration test hangs during route transition

See original GitHub issue

ember-simple-auth config:

App.initializer({

  initialize: function(container, application) {
    Ember.SimpleAuth.setup(container, application, {
      loginRoute: 'user.login',
      routeAfterLogin: '/user/dashboard',
      routeAfterLogout: '/user/login',
      serverTokenEndpoint: '/api/token',
    });
  }
});

The Test:

test("Visit login page", function() {
  expect(1);
  visit("/user/login");
  andThen(function() {
    ok(true);
   });
});

The problem:

The test hangs during the route transition.

DEBUG: 'DEBUG: -------------------------------'
DEBUG: 'DEBUG: Ember      : 1.2.0-beta.3'
DEBUG: 'DEBUG: Ember Data : 1.0.0-beta.2'
DEBUG: 'DEBUG: Handlebars : 1.1.2'
DEBUG: 'DEBUG: jQuery     : 1.9.1'
DEBUG: 'DEBUG: -------------------------------'
INFO: 'generated -> route:user', Object{fullName: 'route:user'}
INFO: 'Rendering application with default view <appkit@view:toplevel::ember296>', Object{fullName: 'view:application'}
INFO: 'generated -> controller:user', Object{fullName: 'controller:user'}
INFO: 'Rendering user with default view <appkit@view:default::ember317>', Object{fullName: 'view:user'}
INFO: 'Rendering user.login with default view <appkit@view:default::ember329>', Object{fullName: 'view:user.login'}
LOG: 'Transitioned into 'user.login''
INFO: 'generated -> route:user', Object{fullName: 'route:user'}
INFO: 'Rendering application with default view <appkit@view:toplevel::ember398>', Object{fullName: 'view:application'}
INFO: 'generated -> controller:user', Object{fullName: 'controller:user'}
INFO: 'Rendering user with default view <appkit@view:default::ember416>', Object{fullName: 'view:user'}
INFO: 'Rendering user.login with default view <appkit@view:default::ember422>', Object{fullName: 'view:user.login'}
LOG: 'Transitioned into 'user.login''
LOG: 'Transitioned into 'user.login''

Hangs right here

The test will finish if I override the init function in simple-auth and strip out the body of that function. I think maybe there is an async call in init that isn’t resolving or something?

Other than this test failing, ember-simple-auth is working as expected. All protected routes require login and the session object is being returned correctly.

FYI this is within an ember app kit project.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AlphaGitcommented, Feb 14, 2014

Since I arrived with this exact same problem, I believe I can provide more info for future visitors, even knowing that this issue has already been addressed.

Most of the actions that Ember.testing executes (like visit) will append to a promise that gets executed action after action in the right order. In order to pass to the next action, Ember.testing makes sure that there is nothing pending, so that the step can be considered complete and move forward.

Along with the things that are tested for, pending AJAX requests are verified, and also scheduled timers. These timers may arise from, you guessed it, Ember.run.later calls. If for any reason you would have in your code periodic Ember.run.later methods (so that one is always waiting to be excuted), it’s likely that you’ll face this issue.

I’ve faced it myself in a similar scenario: My server returns a OAuth access token with 100 hours until expired, so ember-simpleAuth registers a call close to the expiration time with Ember.run.later to refresh the token. This will, however, prevent the test from moving along. My specific situations has been fixed in further versions but any similar behavior will reproduce the issue (which is likely a conclusion of the current design of Ember.testing).

Hope this helps to anyone with this issue, and sorry for the wall of text.

0reactions
fibigergcommented, May 29, 2014

@AlphaGit +1 I have just hotfixed it by commenting the line while testing 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

QUnit integration test hangs during route transition #35 - GitHub
The problem: The test hangs during the route transition. ... The test will finish if I override the init function in simple-auth and...
Read more >
transitionToRoute causes ember test to hang - Stack Overflow
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...
Read more >
Ember integration testing hangs after visiting route-ember.js
The issue is that the async helper visit() waits for the Ember.run.later() to finish, but the way I have this structured, before it...
Read more >
Testing Routes - Ember Guides
Testing routes can be done both via application tests or container tests. ... transitions and load data, both of which are tested more...
Read more >
Test-Driving Ember.js Components - Semaphore CI
Dive back into Ember and learn about templates and components in a new tutorial in our "Test-Driving an Ember.js Application" series.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found