@pkenway Maybe use Em.run.later(function(par){doStuff()}, 9000)
This is a really great and helpful post.
I’m noticing that in a initializer ( for our session/user validation) using Em.run.begin() and Em.run.end() are not functioning as expected - namely the Test fails with 0 expections being met or processed.
I’ve been trying to create a semaphore/mutex state that works similar to
application.deferReadiness / advanceReadiness -
these work like a charm when the initializer is booting - but then there is a similar requirement in our session object to block application process when the session changes (login , logout , login )
My questions are:
Is there an established way to create synchronization blocks?
Can you share an example of the code?
Guys, Could you please elaborate on this one and give exact example with Ember.RSVP. Lets take RSVP.Promise
If you use Ember.RSVP or a library that uses RSVP.js library to create a promise, you’ll have to wrap the creating code in Ember.run.
Further: I have a problem that while testing I am getting Assert message even though I have code wrapped in Ember.run loop.
This is the function
MyPlugin.client.session.attachUser(credentials, callback(error, success){
handle error
handle success
})
This function is used like this
login(
return new Ember.RSVP.Promise( (resolve, reject) => {
MyPlugin.client.session.attachUser(credentials, (error, success) => {
...handle reject
return reject(err)
..handle resolve
return resolve(success)
})
})
)
Function call above in MyPlugin has an ajax call and has promise handling inside it self and invokes callback when call is done. I tried different paths, but wrapping whole Ember.RSVP in Ember.run still produce error.
Error comes if use Ember.run as in code it self as in tests as well. This function is run on click on form’s button.
So doing click in test will just stall everything and test is not finished
click('#selector-for-button')
produces Uncaught 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
Hi, i’m running into this particular problem here but the odd thing is that when i run “ember test” on my own PC it works just fine and all tests passes but when i run the test via CI (my office uses Jenkins) this error comes up always on one particular test. Now when i use /**/ comment on the test block and run the test again via CI, the error moves to the test that comes afterwards. So i moved on into seeing the controller that is being tested and there seems to be none of any operations that has async side-effects
i’ve asked my senior on how could this difference happen (local passes but CI fails) and he says it’s because tests on CI runs headlessly. i tried to look for documentations, blogs, and stuff for qunit xvfb+firefox but i guess not many uses this method to test their apps.
i’m using qunit and xvfb + Firefox 46.0 for the acceptance test that ran into this error