Pregunta

So I've got my lovely testing system all ready to go but i've run into a problem for running it in in my CI server: for some reason Ember Testing is complaining about the run-loop, but only while running in PhantomJS

Here is the Karma output:

Waiting for previous execution...
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: -------------------------------'
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: Ember      : 1.4.0'
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: Ember Data : 1.0.0-beta.7+canary.b45e23ba'
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: Handlebars : 1.0.0'
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: jQuery     : 1.9.1'
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: -------------------------------'
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: -------------------------------'
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: Ember      : 1.4.0'
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: Ember Data : 1.0.0-beta.7+canary.b45e23ba'
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: Handlebars : 1.0.0'
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: jQuery     : 1.9.1'
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: -------------------------------'
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: For more advanced debugging, install the Ember Inspector from https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi'
PhantomJS 1.9.7 (Linux) ERROR
    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 an Ember.run
    at /apps/contentpartnerpages/ember/app/bower_components/ember/ember.js:73
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.743 secs: Chats Filter tests verify adding one chat to the store
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.649 secs: Chats Filter tests verify number of missed chats
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.763 secs: Chats Filter tests verify the sparklines update
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.657 secs: Chats Filter tests verify global filters apply to child controllers
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.783 secs: Chats Filter tests verify local filters work with global filters
PhantomJS 1.9.7 (Linux): Executed 0 of 0 ERROR (0.642 secs / 0 secs)
Chrome 33.0.1750 (Mac OS X 10.9.1): Executed 6 of 6 SUCCESS (4.301 secs / 3.966 secs)

As you can see they are clearly working in chrome! I can't think what would be different but if someone could point me in the right direction that would be awesome.

¿Fue útil?

Solución

It's odd that this is only happening on the chrome, but nevertheless, the problem is most likely to be that in one of your tests, you are having async issues. Isolate and find the test that is causing this problem, and then see which parts of your code it touches. Then, you need to make sure that in that code (including observers which fire) set, create, destroy, and ajax calls are wrapped in the ember run loop:

Ember.run(function(){
  // all call that results in asynchronous operations goes here
});

Once that is done, your problem will most likely go away! Also, make sure to use have "waitFor" or "andThen" function (depends on testing framework) after an async call that waits for async call to finish. Let me know if that works.

Source:

http://discuss.emberjs.com/t/guide-asynchronous-side-effects-in-testing/2905

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top