Ember acceptance test - timeouts


Hi all lovely people,

I have a reasonably special use-case: I have an input field which issues a search when the user has stopped typing for 500ms. This is developed as a reusable add-on. Nothing really fancy and it works fine with Ember.run.later.

I would like to write an acceptance test for this but I cannot make the tests pass properly. The first passes, the second doesn’t.

Now, the Ember runloop has a nice description but it’s behaviour is really “something else”.

This is my helper to timeout the runloop:

import Ember from 'ember';

export default Ember.Test.registerAsyncHelper('pauseFor', function (time) {
  return Ember.Test.promise(function (resolve) {
    Ember.run.later(resolve, time);

And this is how I use it

it('should do something after 500ms', function () {

  fillIn('.search-input', 'a');

  andThen(function () {
    // do my assertions/expectations here...

I am not allowed to post new pics yet but the original question with the attached shot of the error can be found here: http://stackoverflow.com/questions/29987294/ember-acceptance-test-timeouts

The weird thing is that I have 2 test cases and the first passes happily.

I guess my question is: How to do this properly? What am I missing here or what am I doing wrong? How can I just simply timeout the test case?

Thanks for the halp in advance! =)


run.later can have some unexpected consequences when doing testing https://github.com/emberjs/ember.js/issues/3008 have you tried using a javascript timeout instead of run.later.


Ah. Thanks for the tip, I’ve done a refactor based on a the workaround - following that link. I’ll soon post the result too.


Just for reference, this works for me:

  Ember.Test.promise(function(resolve) {
    window.setTimeout(resolve, 1500);