QUnit integration test hangs during route transition
See original GitHub issueember-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:
- Created 10 years ago
- Comments:11 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 periodicEmber.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.
@AlphaGit +1 I have just hotfixed it by commenting the line while testing 😃