Skip to content

Instantly share code, notes, and snippets.

@biscuitvile
Forked from mikepack/gist:7900448
Created December 11, 2013 23:02
Show Gist options
  • Save biscuitvile/7920114 to your computer and use it in GitHub Desktop.
Save biscuitvile/7920114 to your computer and use it in GitHub Desktop.

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment