-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong context in asyncTest (using callbacks given to moduleFor instead of extended callbacks) #98
Comments
@huafu the idea is to use promises, and return promises in the main callback whenever one would need an async test. This typically provides a nicer asyncTest experience as it does all the start/stop balancing for you and also preserves context. |
Sorry but do you have an example of how to do an async test with promises and |
test('do something async', function() {
return new Ember.RSVP.Promise(function(resolve, reject) {
/* do something that does async */
setTimeout(function() {
/* when the async is done */
resolve();
}, 10);
});
}); |
Haha as simple as this! Thank you I wouldn't think it was that simple, forgot test where waiting for promise and other delayed stuff to finish, thanks a lot! Huafu Gandon Try Panomira.
|
Awesomely the latest Qunit will support this promise behavior right out of the box! |
Using
moduleFor
is extending the 3rd argument (callbacks
) to injectsubject
for example. This works forsetup
,teardown
and anytest
, but anyasyncTest
has the un-modifiedcallbacks
given as 3rd argument tomoduleFor
instead of the one wheresubject
has been injected.In result, calling
this.subject()
in anasyncTest
is failing sincesubject
is thenundefined
The text was updated successfully, but these errors were encountered: