Emberjs: Test with Pavlov / Qunit produces TypeError: Object # & lt; Object & gt; Does not have 'getHandler'


Warning: I am a newbie. Thanks in advance for any help.

Pavlov/QUnit is causing problems with the router in my ember app. When using QUnit alone, the following test passes:

test "/contacts", ->
  visit('/contacts').then ->
    ok(exists(".nav"), "The navbar was rendered")

But when using Pavlov with QUnit, the following test dies:

describe 'contacts index', ->
    it 'does render index', ->
      visit('/contacts').then ->
        assert(exists(".nav")).isTrue('The navbar was rendered')

and produces a "has no method 'getHandler'" error in the collectObjects method when the following is executed:

var handler = router.getHandler(result.handler);

Stack trace is below:

TypeError: Object #<Object> has no method 'getHandler'
    at collectObjects (http://localhost:3000/assets/test_helper.js:37674:28)
    at Object.Router.handleURL (http://localhost:3000/assets/test_helper.js:37347:9)
    at Ember.Router.Ember.Object.extend.handleURL (http://localhost:3000/assets/test_helper.js:38135:17)
    at Ember.Application.Ember.Namespace.extend.handleURL (http://localhost:3000/assets/test_helper.js:41451:12)
    at http://localhost:3000/assets/test_helper.js:18367:19
    at Object.Ember.handleErrors (http://localhost:3000/assets/test_helper.js:14228:17)
    at invoke (http://localhost:3000/assets/test_helper.js:18365:16)
    at Object.tryable (http://localhost:3000/assets/test_helper.js:18550:14)
    at Object.Ember.tryFinally (http://localhost:3000/assets/test_helper.js:15023:24)
    at Object.Ember.run (http://localhost:3000/assets/test_helper.js:18554:16)

I just had the same problem with QUnit. The tests were starting before my Ember application was ready, so calls to visit() would fail.

Try turning the QUnit autostart flag to false (http://api.qunitjs.com/QUnit.config/) and call QUnit.start() from your application ready callback. That fixed it for me, if you need more help you can look at this repo: https://github.com/remichaignon/ember-boilerplate