emberjs:使用Pavlov / QUnit进行测试会产生TypeError:Object#< Object>没有方法'getHandler' [英] emberjs: Testing with Pavlov/QUnit produces TypeError: Object #<Object> has no method 'getHandler'

查看:85
本文介绍了emberjs:使用Pavlov / QUnit进行测试会产生TypeError:Object#< Object>没有方法'getHandler'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

警告:我是新手。提前感谢任何帮助。



Pavlov / QUnit在我的ember应用程序中导致路由器出现问题。当单独使用QUnit时,以下测试通过:

  test/ contacts, - > 
expect(1)
visit('/ contacts')然后 - >
ok(exists(。nav),导航栏被渲染)

但是当使用Pavlov与QUnit时,以下测试会死亡:

 描述'contacts index', - > 
它'渲染索引', - >
访问('/ contacts')然后 - >
assert(exists(。nav))。isTrue('导航栏被渲染')

并且在执行以下操作时在collectObjects方法中产生没有方法getHandler'错误:


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


堆栈跟踪如下:

  TypeError:Object#< Object>没有方法'getHandler'
在collectObjects(http:// localhost:3000 / assets / test_helper.js:37674:28)
在Object.Router.handleURL(http:// localhost:3000 /资产/ test_helper.js:37347:9)
在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)
在http:// localhost:3000 / assets / test_helper.js:18367 :$ 19
在Object.Ember.handleErrors(http:// localhost:3000 / assets / test_helper.js:14228:17)
在invoke(http:// localhost:3000 / assets / test_helper。 js:18365:16)
在Object.tryable(http:// localhost:3000 / assets / test_helper.js:18550:14)
在Object.Ember.tryFinally(http:// localhost: 3000 / assets / test_helper.js:15023:24)
在Object.Ember.run(http:// localhost:3000 / assets / test_helper.js:18554:16)


解决方案

我刚刚他与QUnit同样的问题。测试开始于我的Ember应用程序准备就绪之前,所以调用 visit()将失败。



QUICK自动启动标志为false( http://api.qunitjs.com/QUnit.config/),并从您的应用程序中调用 QUnit.start()。如果您需要更多帮助,可以查看此回购: https://github.com / remichaignon / ember-sheetsplate


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", ->
  expect(1)
  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

这篇关于emberjs:使用Pavlov / QUnit进行测试会产生TypeError:Object#&lt; Object&gt;没有方法'getHandler'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆