@ppcano wrote:
I would like to get some feedback on the use of
registerWaiterin an async helper to wait for animated components to appear.In our acceptance tests, the
waitUntilhelper could be used as:waitUntil('#my-button'); click('#my-button');or
waitUntil('#my-modal.modal').then(function() { var el = find('#my-modal.modal'); assert.ok(el.length > 0, 'modal was open'); .... });Below the helper implementation:
Ember.Test.registerAsyncHelper('waitUntil', function(app, selector, callback) { var waiter = function() { return $(selector).length > 0; }; Ember.Test.registerWaiter(waiter); var promise = app.testHelpers.wait(); promise.then(function() { Ember.Test.unregisterWaiter(waiter); }); // it will be resolved when the pending events have been processed // (routing loads, ajax requests, run loops and waiters) return promise;});
I think, this could be a common use of
registerWaiterwhich could be added to the documentation.
Posts: 1
Participants: 1