I get odd results with Ember andThen and click test andThen . According to the Ember documentation:
the assistant andThen will wait for all previous asynchronous helpers to complete before moving forward.
However, I believe that this is not always the case. In the example below, there are 3 console.debug statements. I would expect them to be written in the order A → B → C. But I sequentially get this order: A → C → B. I can only get the expected ABC order when I use only one of the two clicks helpers. There are no event (action) listeners associated with the <div> element specified in clicks.
Can someone explain this unexpected behavior? Is there a mistake in using helpers? Or a bug with the Ember testing platform?
andThen(function() { console.debug('mark A'); click('div:first'); // with just 1 click helper, debug order is ABC click('div:first'); // with this second click helper, debug order is ACB andThen(function() { console.debug('mark B'); }); }); andThen(function() { console.debug('mark C'); });
Edit :
Based on Kingpin2k's answer, I ended up working on the next solution to get the testing style I was looking for.
First, I created an asynchronous test helper called next . Secondly, I replaced all andThen helpers in my code with special next helpers. This allowed my code to work in the order I expected.
// test-helper.js Ember.Test.registerAsyncHelper('next', function(app, fn) { fn(); }); // my-integration-test.js next(function() { console.debug('mark A'); click('div:first'); click('div:first'); next(function() { console.debug('mark B'); }); }); next(function() { console.debug('mark C'); });
source share