I have a component that integrates 2 third-party libraries, imagesLoaded and Isotope.
I get conflicting test failures when running tests in the browser and cli mode. The error is:
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
When I try to wrap callbacks in an ember run loop, they pass in cli-mode, but then fail in browser mode. I can't seem to find the right combination. The issue seems to happen in the callback of imagesLoaded, as if I remove that plugin, it seems to pass fine.
I've tried multiple combinations, but here is my latest code. If anyone has insight on how to properly use the run loop in this component, that would be helpful.
import Ember from 'ember';
export default Ember.View.extend({
classNames: ['masonry'],
handleLoad: function() {
let self = this;
Ember.run.scheduleOnce('afterRender', this, function(){
this.$().imagesLoaded( function() {
Ember.run.schedule('actions', this, function(){
let $container = self.$().isotope({itemSelector: ".card-container"});
$container.isotope('shuffle');
}); // Ember.run
}); // imagesLoaded
}); // Ember.run
}.on('didInsertElement')
});
Aucun commentaire:
Enregistrer un commentaire