We've recently started to use the undocumented Ember.testing flag in our jasmine specs which effectively disables the autorun runloop feature. We've found that this requires us to be quite a bit more explicit about manually wrapping code in runloops but has also given us more stability in our specs as it highlights problems in the way we've written the spec and helps to document when bindings are important to the code under test.
Is there an official line on the usage of this feature ? It appears to have had quite a positive impact in our app but I suspect most people aren't aware of it.
Yes, you should definitely set Ember.testing = true
in your tests.
Without Ember.testing
, runloops are scheduled automatically with setTimeout
, which is where the instability you're noting comes from.
Note: At the moment, when you activate Ember.testing
, you necessarily end up prefixing many of the lines in your test code with Em.run =>
, like
Em.run => obj.set('someProperty', true)
If you forget to, it will complain loudly, or properties/app state won't have updated when you try to run assertions against it.
Maybe this will be improved some day, but for now it's nothing to be worried about if your test code is sprinkled with run
calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With