When testing Ember code, without putting expectations in a Ember.run
callback, you'll get this error:
Failure/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
The error recommends wrapping expectations in Ember.run
:
describe 'something', ->
it 'does something', ->
Ember.run ->
expect(1).to.eql(1)
Ember.run
is noisy and adds no value to test comprehension, so we can remove it by controlling the runloop manually.
In spec_helper.coffee
:
Ember.testing = true
beforeEach -> Ember.run.begin()
afterEach -> Ember.run.sync()