1
votes

I'm using jQuery File Upload as a ember component. This plugin has an API which lets me interact with file uploads programmatically in tests. This works perfectly in component tests. However in Acceptance tests I get this error:

Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run

A snippet from my test:

// some steps before this.

andThen(() => {
  Ember.run(() => {
     find('.file-upload').fileupload('send', { files: [{name: 'file.doc' }] });
    });
  });
});

Any pointers would be much appreciated.

1

1 Answers

1
votes

I ran into this a while back. To handle this, you will have to wrap your actual component code(not the test code) that is asynchronous in an Ember.run loop. Having this will not affect your program as this will be merged with the application's main run loop.

This makes the code execute asynchronously while testing.

Refer here for more info on this: http://discuss.emberjs.com/t/guide-asynchronous-side-effects-in-testing/2905