Is it recommended to set Ember.testing = true for unit tests?

We recently started using the undocumented Ember.testing flag in our jasmine specifications, which effectively disables the runloop autostart function. We found that this requires us to be more explicit about manually wrapping code in runloops, but also give us greater stability in our specifications, as this underlines the problems in how we wrote the specification and helps to document when bindings are important for code under test.

Is there an official line for using this feature? Apparently, this had a positive effect on our application, but I suspect that most people do not know this.

+8
source share
2 answers

Yes, you should definitely set Ember.testing = true in your tests.

Without Ember.testing , runloops are automatically assigned using setTimeout , where the instability you noticed comes from.

Note. At the moment, when you activate Ember.testing , you must prefix many lines in your test code with Em.run => , for example

 Em.run => obj.set('someProperty', true) 

If you forget, he will complain loudly, otherwise the state of the properties / applications will not be updated when trying to execute statements against him.

This may be improved someday, but for now, don’t worry about your test code being sprinkled with run calls.

+7
source share

I have never used the Ember.testing flag. I would be interested to know how this led to more stability in your specifications. I tested the Ember applications in Jasmine without any problems.

I had success after using the Ember Ember.run() and Ember.run.sync() test suite, if necessary.

-one
source share

All Articles