Skip to content

Instantly share code, notes, and snippets.

@mikepack
Last active December 30, 2015 23:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikepack/7900448 to your computer and use it in GitHub Desktop.
Save mikepack/7900448 to your computer and use it in GitHub Desktop.
Removing Ember.run from all (Jasmine) tests

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()
@dbackeus
Copy link

This sort of worked for us but we had to change Ember.run.sync() to Ember.run.stop()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment